Bagikan melalui


Memperbarui Layanan Cloud Azure (dukungan yang diperluas)

Sampel ini mencakup berbagai cara untuk memperbarui penyebaran Azure Cloud Service (dukungan yang diperpanjang) yang ada.

Menambahkan ekstensi ke Layanan Cloud yang sudah ada

Kumpulan perintah di bawah ini menambahkan ekstensi RDP ke layanan cloud yang sudah ada bernama ContosoCS yang termasuk dalam grup sumber daya bernama 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

hapus semua ekstensi dari Layanan Cloud

Kumpulan perintah di bawah ini menghapus semua ekstensi dari layanan cloud yang ada bernama ContosoCS yang termasuk dalam grup sumber daya bernama 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

hapus ekstensi desktop jarak jauh dari Cloud Service

Kumpulan perintah di bawah ini menghapus ekstensi RDP dari layanan cloud yang ada bernama ContosoCS yang termasuk dalam grup sumber daya bernama 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

Contoh peran scale-out / scale-in

Kumpulan perintah di bawah ini menunjukkan cara menskalakan dan meningkatkan jumlah instans peran untuk layanan cloud bernama ContosoCS yang termasuk dalam grup sumber daya bernama 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

Langkah berikutnya

Untuk informasi selengkapnya tentang Azure Cloud Services (dukungan yang diperluas), lihat Gambaran umum Azure Cloud Services (dukungan yang diperpanjang).