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>]
Description
建立或更新雲端服務。 請注意,某些屬性只能在雲端服務建立期間設定。
範例
範例 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
上述一組命令會從金鑰保存庫建立具有單一角色和憑證的雲端服務。
範例 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
上述一組命令會從金鑰保存庫建立具有單一角色和憑證的雲端服務。
範例 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,參考 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
指定參考 Blob 服務中服務套件位置的 URL。 服務套件 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,直到您呼叫 Start 為止,此時服務將會啟動。
即使已部署的服務已關閉,仍會產生費用。
類型: | SwitchParameter |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-StorageAccount
將儲存封裝檔案的記憶體帳戶名稱。
類型: | String |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | False |
接受萬用字元: | False |
-SubscriptionId
可唯一識別Microsoft Azure 訂用帳戶的訂用帳戶認證。 訂用帳戶標識碼會形成每個服務呼叫 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 />manual<br /><br />同時<br /><br />如果未指定,預設值為 Auto。如果設定為 Manual,則必須呼叫 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 |