更新 Azure 云服务(外延支持)

这些示例涵盖了更新现有 Azure 云服务(外延支持)部署的各种方式。

将扩展添加到现有云服务

下面的命令集将 RDP 扩展添加到名为 ContosoCS 的现有云服务,该服务属于名为 ContosOrg 的资源组。

# Create RDP extension object
$rdpExtension = New-AzCloudServiceRemoteDesktopExtensionObject -Name "RDPExtension" -Credential $credential -Expiration $expiration -TypeHandlerVersion "1.2.1"
# Get existing cloud service
$cloudService = Get-AzCloudService -ResourceGroup "ContosOrg" -CloudServiceName "ContosoCS"
# Add RDP extension to existing cloud service extension object
$cloudService.ExtensionProfile.Extension = $cloudService.ExtensionProfile.Extension + $rdpExtension
# Update cloud service
$cloudService | Update-AzCloudService

从云服务中删除所有扩展

下面的命令集将所有扩展从名为 ContosoCS 的现有云服务中删除,该服务属于名为 ContosOrg 的资源组。

# Get existing cloud service
$cloudService = Get-AzCloudService -ResourceGroup "ContosOrg" -CloudServiceName "ContosoCS"
# Set extension to empty list
$cloudService.ExtensionProfile.Extension = @()
# Update cloud service
$cloudService | Update-AzCloudService

从云服务中删除远程桌面扩展

下面的命令集将 RDP 扩展从名为 ContosoCS 的现有云服务中删除,该服务属于名为 ContosOrg 的资源组。

# Get existing cloud service
$cloudService = Get-AzCloudService -ResourceGroup "ContosOrg" -CloudServiceName "ContosoCS"
# Remove extension by name RDPExtension
$cloudService.ExtensionProfile.Extension = $cloudService.ExtensionProfile.Extension | Where-Object { $_.Name -ne "RDPExtension" }
# Update cloud service
$cloudService | Update-AzCloudService

横向扩展/横向缩减实例

下面的命令集显示如何为名为 ContosoCS 的云服务(属于名为 ContosOrg 的资源组)横向扩展和横向缩减角色实例计数。

# Get existing cloud service
$cloudService = Get-AzCloudService -ResourceGroup "ContosOrg" -CloudServiceName "ContosoCS"

# Scale-out all role instance count by 1
$cloudService.RoleProfile.Role | ForEach-Object {$_.SkuCapacity += 1}

# Scale-in ContosoFrontend role instance count by 1
$role = $cloudService.RoleProfile.Role | Where-Object {$_.Name -eq "ContosoFrontend"}
$role.SkuCapacity -= 1

# Update cloud service configuration as per the new role instance count
$cloudService.Configuration = $configuration

# Update cloud service
$cloudService | Update-AzCloudService

后续步骤

有关 Azure 云服务(外延支持)的详细信息,请参阅 Azure 云服务(外延支持)概述