你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
New-AzCloudService
创建或更新云服务。 请注意,某些属性只能在创建云服务期间设置。
语法
New-AzCloudService
-Name <String>
-ResourceGroupName <String>
[-SubscriptionId <String>]
-Location <String>
[-AllowModelOverride]
[-Configuration <String>]
[-ConfigurationUrl <String>]
[-ExtensionProfile <ICloudServiceExtensionProfile>]
[-NetworkProfile <ICloudServiceNetworkProfile>]
[-OSProfile <ICloudServiceOSProfile>]
[-PackageUrl <String>]
[-RoleProfile <ICloudServiceRoleProfile>]
[-StartCloudService]
[-Tag <Hashtable>]
[-UpgradeMode <CloudServiceUpgradeMode>]
[-Zone <String[]>]
[-DefaultProfile <PSObject>]
[-AsJob]
[-NoWait]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzCloudService
-Name <String>
-ResourceGroupName <String>
[-SubscriptionId <String>]
-Location <String>
[-ExtensionProfile <ICloudServiceExtensionProfile>]
-PackageUrl <String>
[-StartCloudService]
[-Tag <Hashtable>]
[-UpgradeMode <CloudServiceUpgradeMode>]
-ConfigurationFile <String>
-DefinitionFile <String>
[-DnsName <String>]
[-KeyVaultName <String>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzCloudService
-Name <String>
-ResourceGroupName <String>
[-SubscriptionId <String>]
-Location <String>
[-ExtensionProfile <ICloudServiceExtensionProfile>]
[-StartCloudService]
[-Tag <Hashtable>]
[-UpgradeMode <CloudServiceUpgradeMode>]
-ConfigurationFile <String>
-DefinitionFile <String>
-PackageFile <String>
-StorageAccount <String>
[-DnsName <String>]
[-KeyVaultName <String>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
说明
创建或更新云服务。 请注意,某些属性只能在创建云服务期间设置。
示例
示例 1:使用单个角色创建新的云服务
# Create role profile object
$role = New-AzCloudServiceRoleProfilePropertiesObject -Name 'ContosoFrontend' -SkuName 'Standard_D1_v2' -SkuTier 'Standard' -SkuCapacity 2
$roleProfile = @{role = @($role)}
# Create network profile object
$publicIp = Get-AzPublicIpAddress -ResourceGroupName ContosOrg -Name ContosIp
$feIpConfig = New-AzCloudServiceLoadBalancerFrontendIPConfigurationObject -Name 'ContosoFe' -PublicIPAddressId $publicIp.Id
$loadBalancerConfig = New-AzCloudServiceLoadBalancerConfigurationObject -Name 'ContosoLB' -FrontendIPConfiguration $feIpConfig
$networkProfile = @{loadBalancerConfiguration = $loadBalancerConfig}
# Read Configuration File
$cscfgFile = "<Path to cscfg configuration file>"
$cscfgContent = Get-Content $cscfgFile | Out-String
# Create cloud service
$cloudService = New-AzCloudService `
-Name ContosoCS `
-ResourceGroupName ContosOrg `
-Location EastUS `
-PackageUrl "https://xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" `
-Configuration $cscfgContent `
-UpgradeMode 'Auto' `
-RoleProfile $roleProfile `
-NetworkProfile $networkProfile
上述命令集创建具有单个角色的云服务
示例 2:使用单角色和 RDP 扩展创建新的云服务
# Create role profile object
$role = New-AzCloudServiceRoleProfilePropertiesObject -Name 'ContosoFrontend' -SkuName 'Standard_D1_v2' -SkuTier 'Standard' -SkuCapacity 2
$roleProfile = @{role = @($role)}
# Create network profile object
$publicIp = Get-AzPublicIpAddress -ResourceGroupName ContosoOrg -Name ContosIp
$feIpConfig = New-AzCloudServiceLoadBalancerFrontendIPConfigurationObject -Name 'ContosoFe' -PublicIPAddressId $publicIp.Id
$loadBalancerConfig = New-AzCloudServiceLoadBalancerConfigurationObject -Name 'ContosoLB' -FrontendIPConfiguration $feIpConfig
$networkProfile = @{loadBalancerConfiguration = $loadBalancerConfig}
# Create RDP extension object
$credential = Get-Credential
$expiration = (Get-Date).AddYears(1)
$extension = New-AzCloudServiceRemoteDesktopExtensionObject -Name 'RDPExtension' -Credential $credential -Expiration $expiration -TypeHandlerVersion '1.2.1'
$extensionProfile = @{extension = @($extension)}
# Read Configuration File
$cscfgFile = "<Path to cscfg configuration file>"
$cscfgContent = Get-Content $cscfgFile | Out-String
# Create cloud service
$cloudService = New-AzCloudService `
-Name ContosoCS `
-ResourceGroupName ContosOrg `
-Location EastUS `
-PackageUrl "https://xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" `
-Configuration $cscfgContent `
-UpgradeMode 'Auto' `
-RoleProfile $roleProfile `
-NetworkProfile $networkProfile `
-ExtensionProfile $extensionProfile
上述命令集创建具有单个角色和 RDP 扩展的云服务
示例 3:使用密钥保管库中的单个角色和证书创建新的云服务
# Create role profile object
$role = New-AzCloudServiceRoleProfilePropertiesObject -Name 'ContosoFrontend' -SkuName 'Standard_D1_v2' -SkuTier 'Standard' -SkuCapacity 2
$roleProfile = @{role = @($role)}
# Create OS profile object
$keyVault = Get-AzKeyVault -ResourceGroupName ContosOrg -VaultName ContosKeyVault
$certificate=Get-AzKeyVaultCertificate -VaultName ContosKeyVault -Name ContosCert
$secretGroup = New-AzCloudServiceVaultSecretGroupObject -Id $keyVault.ResourceId -CertificateUrl $certificate.SecretId
$osProfile = @{secret = @($secretGroup)}
# Create network profile object
$publicIp = Get-AzPublicIpAddress -ResourceGroupName ContosOrg -Name ContosIp
$feIpConfig = New-AzCloudServiceLoadBalancerFrontendIPConfigurationObject -Name 'ContosoFe' -PublicIPAddressId $publicIp.Id
$loadBalancerConfig = New-AzCloudServiceLoadBalancerConfigurationObject -Name 'ContosoLB' -FrontendIPConfiguration $feIpConfig
$networkProfile = @{loadBalancerConfiguration = $loadBalancerConfig}
# Read Configuration File
$cscfgFile = "<Path to cscfg configuration file>"
$cscfgContent = Get-Content $cscfgFile | Out-String
# Create cloud service
$cloudService = New-AzCloudService `
-Name ContosoCS `
-ResourceGroupName ContosOrg `
-Location EastUS `
-PackageUrl "https://xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" `
-Configuration $cscfgContent `
-UpgradeMode 'Auto' `
-RoleProfile $roleProfile `
-NetworkProfile $networkProfile `
-OSProfile $osProfile
上述一组命令通过 Key Vault 创建具有单个角色和证书的云服务。
示例 4:使用多个角色和扩展创建新的云服务
# Create role profile object
$role1 = New-AzCloudServiceRoleProfilePropertiesObject -Name 'ContosoFrontend' -SkuName 'Standard_D1_v2' -SkuTier 'Standard' -SkuCapacity 2
$role2 = New-AzCloudServiceRoleProfilePropertiesObject -Name 'ContosoBackend' -SkuName 'Standard_D1_v2' -SkuTier 'Standard' -SkuCapacity 2
$roleProfile = @{role = @($role1, $role2)}
# Create network profile object
$publicIp = Get-AzPublicIpAddress -ResourceGroupName ContosOrg -Name ContosIp
$feIpConfig = New-AzCloudServiceLoadBalancerFrontendIPConfigurationObject -Name 'ContosoFe' -PublicIPAddressId $publicIp.Id
$loadBalancerConfig = New-AzCloudServiceLoadBalancerConfigurationObject -Name 'ContosoLB' -FrontendIPConfiguration $feIpConfig
$networkProfile = @{loadBalancerConfiguration = $loadBalancerConfig}
# Create RDP extension object
$credential = Get-Credential
$expiration = (Get-Date).AddYears(1)
$rdpExtension = New-AzCloudServiceRemoteDesktopExtensionObject -Name 'RDPExtension' -Credential $credential -Expiration $expiration -TypeHandlerVersion '1.2.1'
# Create Geneva extension object
$genevaExtension = New-AzCloudServiceExtensionObject -Name GenevaExtension -Publisher Microsoft.Azure.Geneva -Type GenevaMonitoringPaaS -TypeHandlerVersion "2.14.0.2"
$extensionProfile = @{extension = @($rdpExtension, $genevaExtension)}
# Add tags
$tag=@{"Owner" = "Contoso"}
# Read Configuration File
$cscfgFile = "<Path to cscfg configuration file>"
$cscfgContent = Get-Content $cscfgFile | Out-String
# Create cloud service
$cloudService = New-AzCloudService `
-Name ContosoCS `
-ResourceGroupName ContosOrg `
-Location EastUS `
-PackageUrl "https://xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" `
-Configuration $cscfgContent `
-UpgradeMode 'Auto' `
-RoleProfile $roleProfile `
-NetworkProfile $networkProfile `
-ExtensionProfile $extensionProfile `
-Tag $tag
上述一组命令通过 Key Vault 创建具有单个角色和证书的云服务。
示例 5:使用“quickCreateParameterSetWithStorage”参数集使用 CsCfg、CsDef 和 Cspkg 文件创建新的云服务。
# Set up a storage account if you have not
$storageAccount = New-AzStorageAccount -ResourceGroupName ContosoOrg -Name ContosoStorAcc -Location "East US" -SkuName "Standard_RAGRS" -Kind "StorageV2"
# Create cloud service
$cloudService = New-AzCloudService `
-Name ContosoCS `
-ResourceGroupName ContosOrg `
-Location EastUS `
-ConfigurationFile C:\files\CS.cscfg `
-DefinitionFile C:\files\CS.csdef `
-PackageFile C:\CS.cspkg `
-StorageAccount ContosoStorAcc `
-KeyVaultName ContosoKV
上述命令集通过从 中提取 NetworkProfile 和 RoleProfile 信息来创建云服务。CsCfg 和 .CsDef 文件。
这些文件还将提供 OSProfile 信息,以及“-KeyVaultName”参数中提供的 keyvault 中的证书。 此参数集还会上传 .CsPkg 文件到提供的 StorageAccount。
示例 6:使用“quickCreateParameterSetWithoutStorage”参数集使用 CsCfg、CsDef 和 Cspkg 文件创建新的云服务。
# getting Package URL
$tokenStartTime = Get-Date
$tokenEndTime = $tokenStartTime.AddYears(1)
$storAcc = Get-AzStorageAccount -ResourceGroupName ContosoOrg -Name ContosoStorAcc
$csPkgBlob = Get-AzStorageBlob -Container Contoso-Container -Blob ContosoBlob.cspkg -Context $storAcc.Context
$csPkgToken = New-AzStorageBlobSASToken -Container Contoso-Container -Blob ContosoBlob.cspkg -Permission rwd -StartTime $tokenStartTime -ExpiryTime $tokenEndTime -Context $storAcc.Context
$cspkgUrl = $csPkgBlob.ICloudBlob.Uri.AbsoluteUri + $csPkgToken
# Create cloud service
$cloudService = New-AzCloudService `
-Name ContosoCS `
-ResourceGroupName ContosOrg `
-Location EastUS `
-ConfigurationFile C:\files\CS.cscfg `
-DefinitionFile C:\files\CS.csdef `
-packageUrl $cspkgUrl `
上述命令集通过从 中提取 NetworkProfile 和 RoleProfile 信息来创建云服务。CsCfg 和 .CsDef 文件。
这些文件还将提供 OSProfile 信息,以及“-KeyVaultName”参数中提供的 keyvault 中的证书。
参数
-AllowModelOverride
(可选)指示模型/模板中指定的角色 SKU 属性(roleProfile.roles.sku)是否应分别替代 .cscfg 和 .csdef 中指定的角色实例计数和 VM 大小。默认值为 false
。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-AsJob
以作业身份运行命令
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Configuration
指定云服务的 XML 服务配置(.cscfg)。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-ConfigurationFile
指定云服务的 XML 服务配置(.cscfg)。
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-ConfigurationUrl
指定一个 URL,该 URL 引用 Blob 服务中服务配置的位置。 服务包 URL 可以是任何存储帐户中的共享访问签名 (SAS) URI。这是一个仅写属性,不会在 GET 调用中返回。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Confirm
在运行 cmdlet 之前,提示你进行确认。
类型: | SwitchParameter |
别名: | cf |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-DefaultProfile
DefaultProfile 参数不起作用。 如果对其他订阅执行 cmdlet,请使用 SubscriptionId 参数。
类型: | PSObject |
别名: | AzureRMContext, AzureCredential |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-DefinitionFile
.csdef 文件的路径。
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-DnsName
要用于 CloudService 资源的 Dns 的名称。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-ExtensionProfile
描述云服务扩展配置文件。 若要构造,请参阅 EXTENSIONPROFILE 属性的 NOTES 部分并创建哈希表。
类型: | ICloudServiceExtensionProfile |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-KeyVaultName
要用于 CloudService 资源的 KeyVault 的名称。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Location
资源位置。
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-Name
云服务的名称。
类型: | String |
别名: | CloudServiceName |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-NetworkProfile
云服务的网络配置文件。 若要构造,请参阅 NETWORKPROFILE 属性的 NOTES 部分并创建哈希表。
类型: | ICloudServiceNetworkProfile |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-NoWait
异步运行命令
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-OSProfile
描述云服务的 OS 配置文件。 若要构造,请参阅 OSPROFILE 属性的 NOTES 部分并创建哈希表。
类型: | ICloudServiceOSProfile |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-PackageFile
.cspkg 文件的路径。 它将上传到 Blob
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-PackageUrl
指定一个 URL,该 URL 引用 Blob 服务中的服务包的位置。 服务包 URL 可以是任何存储帐户中的共享访问签名 (SAS) URI。这是一个仅写属性,不会在 GET 调用中返回。
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-ResourceGroupName
资源组的名称。
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-RoleProfile
描述云服务的角色配置文件。 若要构造,请参阅 ROLEPROFILE 属性的 NOTES 部分并创建哈希表。
类型: | ICloudServiceRoleProfile |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-StartCloudService
(可选)指示是否在创建云服务后立即启动云服务。
默认值为 true
。如果为 false,则仍部署服务模型,但代码不会立即运行。
相反,服务是 PoweredOff,直到调用“开始”,此时服务将启动。
即使已部署的服务已关闭,也仍会产生费用。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-StorageAccount
将存储包文件的存储帐户的名称。
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-SubscriptionId
唯一标识 azure 订阅Microsoft的订阅凭据。 订阅 ID 构成了每个服务调用的 URI 的一部分。
类型: | String |
Position: | Named |
默认值: | (Get-AzContext).Subscription.Id |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Tag
资源标记。
类型: | Hashtable |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-UpgradeMode
云服务的更新模式。 部署服务时,角色实例将分配给更新域。 可以在每个更新域中手动启动更新,也可以在所有更新域中自动启动更新。可能的值是 <br /><br />auto<br /><br />手动<br /><br />同时<br /><br />如果未指定,默认值为 Auto。如果设置为“手动”,则必须调用 PUT UpdateDomain 才能应用更新。 如果设置为“自动”,则按顺序自动将更新应用到每个更新域。
类型: | CloudServiceUpgradeMode |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-WhatIf
显示 cmdlet 运行时会发生什么情况。 cmdlet 未运行。
类型: | SwitchParameter |
别名: | wi |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Zone
资源的逻辑可用性区域列表。 列表应仅包含应预配云服务的 1 个区域。 此字段是可选的。
类型: | String[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |