Uwaga
Dostęp do tej strony wymaga autoryzacji. Może spróbować zalogować się lub zmienić katalogi.
Dostęp do tej strony wymaga autoryzacji. Możesz spróbować zmienić katalogi.
Ważne
Od 31 marca 2025 r. usługi w chmurze (wsparcie dodatkowe) są przestarzałe i zostaną w pełni wycofane 31 marca 2027 r. Learn more about this deprecation and how to migrate.
W tym artykule pokazano, jak za pomocą modułu Az.CloudService azure PowerShell utworzyć wdrożenie usług Azure Cloud Services (wsparcie rozszerzone), które ma wiele ról (WebRole i WorkerRole).
Wymagania wstępne
Wykonaj poniższe kroki jako wymagania wstępne dotyczące tworzenia wdrożenia przy użyciu programu Azure PowerShell.
Zapoznaj się z wymaganiami wstępnymi dotyczącymi wdrażania dla usług Cloud Services (rozszerzona pomoc techniczna) i utwórz wymagane zasoby.
Zainstaluj moduł Az.CloudService programu PowerShell:
Install-Module -Name Az.CloudService
Tworzenie nowej grupy zasobów Ten krok jest opcjonalny, jeśli używasz istniejącej grupy zasobów.
New-AzResourceGroup -ResourceGroupName “ContosOrg” -Location “East US”
Utwórz konto magazynu i kontener na platformie Azure, aby przechowywać plik pakietu (cspkg lub .zip) i plik konfiguracji (cscfg) dla wdrożenia usług Cloud Services (rozszerzona pomoc techniczna). You must use a unique name for the storage account name. Ten krok jest opcjonalny, jeśli używasz istniejącego konta magazynowego.
$storageAccount = New-AzStorageAccount -ResourceGroupName “ContosOrg” -Name “contosostorageaccount” -Location “East US” -SkuName “Standard_RAGRS” -Kind “StorageV2” $container = New-AzStorageContainer -Name “contosocontainer” -Context $storageAccount.Context -Permission Blob
Wdrażanie usług Cloud Services (wsparcie dodatkowe)
Aby wdrożyć usługi Cloud Services (rozszerzona obsługa), użyj dowolnej z następujących opcji poleceń cmdlet programu PowerShell:
Quick-create a deployment by using a storage account
- This parameter set inputs the package (.cspkg or .zip) file, the configuration (.cscfg) file, and the definition (.csdef) file for the deployment as inputs with the storage account.
- The cmdlet creates the Cloud Services (extended support) role profile, network profile, and OS profile with minimal input.
- Aby wprowadzić certyfikat, należy określić nazwę magazynu kluczy. The certificate thumbprints in the key vault are validated against the certificates that you specify in the configuration (.cscfg) file for the deployment.
Quick-create a deployment by using a shared access signature URI
- This parameter set inputs the shared access signature (SAS) URI of the package (.cspkg or .zip) file with the local paths to the configuration (.cscfg) file and definition (.csdef) file. No storage account input is required.
- The cmdlet creates the cloud service role profile, network profile, and OS profile minimal input.
- Aby wprowadzić certyfikat, należy określić nazwę magazynu kluczy. The certificate thumbprints in the key vault are validated against the certificates that you specify in the configuration (.cscfg) file for the deployment.
Create a deployment by using a role profile, OS profile, network profile, and extension profile with shared access signature URIs
- Ten zestaw parametrów przyjmuje jako dane wejściowe URI SAS pliku pakietu (.cspkg lub .zip) oraz pliku konfiguracji (.cscfg).
- Należy określić obiekty profilu: profil roli, profil sieciowy, profil systemu operacyjnego i profil rozszerzenia. Profile muszą być zgodne z wartościami ustawionymi w pliku konfiguracji (cscfg) i pliku definicji (csdef).
Quick-create a deployment by using a storage account
Utwórz wdrożenie usług Cloud Services (wsparcie dodatkowe) przy użyciu pliku pakietu (cspkg lub .zip), pliku konfiguracji (cscfg) i plików definicji (csdef):
$cspkgFilePath = "<Path to .cspkg file>"
$cscfgFilePath = "<Path to .cscfg file>"
$csdefFilePath = "<Path to .csdef file>"
# Create a Cloud Services (extended support) deployment
New-AzCloudService
-Name "ContosoCS" `
-ResourceGroupName "ContosOrg" `
-Location "EastUS" `
-ConfigurationFile $cscfgFilePath `
-DefinitionFile $csdefFilePath `
-PackageFile $cspkgFilePath `
-StorageAccount $storageAccount `
[-KeyVaultName <string>]
Szybko stwórz wdrożenie przy użyciu URI SAS
Upload the package (.cspkg or .zip) file for the deployment to the storage account:
$tokenStartTime = Get-Date $tokenEndTime = $tokenStartTime.AddYears(1) $cspkgBlob = Set-AzStorageBlobContent -File “./ContosoApp/ContosoApp.cspkg” -Container “contosocontainer” -Blob “ContosoApp.cspkg” -Context $storageAccount.Context $cspkgToken = New-AzStorageBlobSASToken -Container “contosocontainer” -Blob $cspkgBlob.Name -Permission rwd -StartTime $tokenStartTime -ExpiryTime $tokenEndTime -Context $storageAccount.Context $cspkgUrl = $cspkgBlob.ICloudBlob.Uri.AbsoluteUri + $cspkgToken $cscfgFilePath = "<Path to cscfg file>" $csdefFilePath = "<Path to csdef file>"
Create the Cloud Services (extended support) deployment by using the package (.cspkg or .zip) file, configuration (.cscfg) file, and definition (.csdef) file SAS URI:
New-AzCloudService -Name "ContosoCS" ` -ResourceGroupName "ContosOrg" ` -Location "EastUS" ` -ConfigurationFile $cspkgFilePath ` -DefinitionFile $csdefFilePath ` -PackageURL $cspkgUrl ` [-KeyVaultName <string>]
Create a deployment by using profile objects and SAS URIs
Upload your Cloud Services (extended support) configuration (.cscfg) file to the storage account:
$cscfgBlob = Set-AzStorageBlobContent -File “./ContosoApp/ContosoApp.cscfg” -Container contosocontainer -Blob “ContosoApp.cscfg” -Context $storageAccount.Context $cscfgToken = New-AzStorageBlobSASToken -Container “contosocontainer” -Blob $cscfgBlob.Name -Permission rwd -StartTime $tokenStartTime -ExpiryTime $tokenEndTime -Context $storageAccount.Context $cscfgUrl = $cscfgBlob.ICloudBlob.Uri.AbsoluteUri + $cscfgToken
Upload your Cloud Services (extended support) package (.cspkg or .zip) file to the storage account:
$tokenStartTime = Get-Date $tokenEndTime = $tokenStartTime.AddYears(1) $cspkgBlob = Set-AzStorageBlobContent -File “./ContosoApp/ContosoApp.cspkg” -Container “contosocontainer” -Blob “ContosoApp.cspkg” -Context $storageAccount.Context $cspkgToken = New-AzStorageBlobSASToken -Container “contosocontainer” -Blob $cspkgBlob.Name -Permission rwd -StartTime $tokenStartTime -ExpiryTime $tokenEndTime -Context $storageAccount.Context $cspkgUrl = $cspkgBlob.ICloudBlob.Uri.AbsoluteUri + $cspkgToken
Utwórz sieć wirtualną i podsieć. Ten krok jest opcjonalny, jeśli używasz istniejącej sieci i podsieci. W tym przykładzie użyto jednej sieci wirtualnej i podsieci dla ról usług Cloud Services (rozszerzonej pomocy technicznej) (WebRole i WorkerRole).
$subnet = New-AzVirtualNetworkSubnetConfig -Name "ContosoWebTier1" -AddressPrefix "10.0.0.0/24" -WarningAction SilentlyContinue $virtualNetwork = New-AzVirtualNetwork -Name “ContosoVNet” -Location “East US” -ResourceGroupName “ContosOrg” -AddressPrefix "10.0.0.0/24" -Subnet $subnet
Utwórz publiczny adres IP i ustaw wartość etykiety DNS dla publicznego adresu IP. Cloud Services (extended support) supports only a Basic SKU public IP address. Publiczne adresy IP typu SKU Standard nie działają z usługami chmurowymi (rozszerzona obsługa).
Jeśli używasz statycznego adresu IP, musisz odwołać się do niego jako zastrzeżony adres IP w pliku konfiguracji (cscfg) dla wdrożenia.
$publicIp = New-AzPublicIpAddress -Name “ContosIp” -ResourceGroupName “ContosOrg” -Location “East US” -AllocationMethod Dynamic -IpAddressVersion IPv4 -DomainNameLabel “contosoappdns” -Sku Basic
Utwórz obiekt profilu sieciowego, a następnie skojarz publiczny adres IP z frontonem modułu równoważenia obciążenia. Platforma Azure automatycznie tworzy zasób klasycznego modułu równoważenia obciążenia SKU w tej samej subskrypcji co zasób Cloud Services (rozszerzona pomoc techniczna). Moduł równoważenia obciążenia jest zasobem tylko do odczytu w usłudze Azure Resource Manager. Zasoby można aktualizować tylko za pomocą pliku konfiguracji usługi Cloud Services (rozszerzonej pomocy technicznej) (cscfg) i pliku wdrożenia (csdef).
$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 a key vault. The key vault stores certificates that are associated with Cloud Services (extended support) roles. The key vault must be in the same region and subscription as the Cloud Services (extended support) deployment and have a unique name. Aby uzyskać więcej informacji, zobacz Używanie certyfikatów z usługami Cloud Services (rozszerzona pomoc techniczna).
New-AzKeyVault -Name "ContosKeyVault” -ResourceGroupName “ContosOrg” -Location “East US”
Update the key vault access policy and grant certificate permissions to your user account:
Set-AzKeyVaultAccessPolicy -VaultName 'ContosKeyVault' -ResourceGroupName 'ContosOrg' -EnabledForDeployment Set-AzKeyVaultAccessPolicy -VaultName 'ContosKeyVault' -ResourceGroupName 'ContosOrg' -UserPrincipalName 'user@domain.com' -PermissionsToCertificates create,get,list,delete
Alternatively, set the access policy by using the
ObjectId
value. Aby uzyskaćObjectId
wartość, uruchom polecenieGet-AzADUser
:Set-AzKeyVaultAccessPolicy -VaultName 'ContosKeyVault' -ResourceGroupName 'ContosOrg' -ObjectId 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' -PermissionsToCertificates create,get,list,delete
The following example adds a self-signed certificate to a key vault. Odcisk palca certyfikatu należy dodać poprzez plik konfiguracji (.cscfg) dla ról Usług w Chmurze (rozszerzona obsługa).
$Policy = New-AzKeyVaultCertificatePolicy -SecretContentType "application/x-pkcs12" -SubjectName "CN=contoso.com" -IssuerName "Self" -ValidityInMonths 6 -ReuseKeyOnRenewal Add-AzKeyVaultCertificate -VaultName "ContosKeyVault" -Name "ContosCert" -CertificatePolicy $Policy
Utwórz obiekt profilu systemu operacyjnego w pamięci. Profil systemu operacyjnego określa certyfikaty skojarzone z rolami usług Cloud Services (rozszerzona obsługa), czyli certyfikatem utworzonym w poprzednim kroku.
$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 a role profile in-memory object. Profil roli definiuje właściwości specyficzne dla SKU danej roli, takie jak nazwa, wydajność i poziom. W tym przykładzie zdefiniowano dwie role: frontendRole i backendRole. Informacje o profilu roli muszą być zgodne z konfiguracją roli zdefiniowaną w pliku konfiguracji wdrożenia (cscfg) i pliku definicji (csdef).
$frontendRole = New-AzCloudServiceRoleProfilePropertiesObject -Name 'ContosoFrontend' -SkuName 'Standard_D1_v2' -SkuTier 'Standard' -SkuCapacity 2 $backendRole = New-AzCloudServiceRoleProfilePropertiesObject -Name 'ContosoBackend' -SkuName 'Standard_D1_v2' -SkuTier 'Standard' -SkuCapacity 2 $roleProfile = @{role = @($frontendRole, $backendRole)}
(Opcjonalnie) Utwórz obiekt profilu rozszerzenia w pamięci, aby dodać go do wdrożenia usług Cloud Services (rozszerzonej pomocy technicznej). W tym przykładzie dodano rozszerzenie protokołu RDP (Remote Desktop Protocol):
$credential = Get-Credential $expiration = (Get-Date).AddYears(1) $rdpExtension = New-AzCloudServiceRemoteDesktopExtensionObject -Name 'RDPExtension' -Credential $credential -Expiration $expiration -TypeHandlerVersion '1.2.1' $storageAccountKey = Get-AzStorageAccountKey -ResourceGroupName "ContosOrg" -Name "contosostorageaccount" $configFile = "<WAD public configuration file path>" $wadExtension = New-AzCloudServiceDiagnosticsExtension -Name "WADExtension" -ResourceGroupName "ContosOrg" -CloudServiceName "ContosCS" -StorageAccountName "contosostorageaccount" -StorageAccountKey $storageAccountKey[0].Value -DiagnosticsConfigurationPath $configFile -TypeHandlerVersion "1.5" -AutoUpgradeMinorVersion $true $extensionProfile = @{extension = @($rdpExtension, $wadExtension)}
Plik konfiguracji (cscfg) powinien zawierać tylko
PublicConfig
tagi i powinien zawierać przestrzeń nazw, jak pokazano w poniższym przykładzie:<?xml version="1.0" encoding="utf-8"?> <PublicConfig xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration"> ............... </PublicConfig>
(Opcjonalnie) W tabeli skrótów programu PowerShell można zdefiniować tagi, które mają zostać dodane do wdrożenia:
$tag=@{"Owner" = "Contoso"}
Create the Cloud Services (extended support) deployment by using the profile objects and SAS URIs that you defined:
$cloudService = New-AzCloudService ` -Name “ContosoCS” ` -ResourceGroupName “ContosOrg” ` -Location “East US” ` -PackageUrl $cspkgUrl ` -ConfigurationUrl $cscfgUrl ` -UpgradeMode 'Auto' ` -RoleProfile $roleProfile ` -NetworkProfile $networkProfile ` -ExtensionProfile $extensionProfile ` -OSProfile $osProfile ` -Tag $tag
Powiązana zawartość
- Zapoznaj się z często zadawanymi pytaniami dotyczącymi usług Cloud Services (rozszerzona pomoc techniczna).
- Wdrażanie usług Cloud Services (wsparcie dodatkowe) przy użyciu witryny Azure Portal, szablonu usługi ARM lub programu Visual Studio.
- Odwiedź repozytorium przykładów usług Cloud Services (rozszerzonej pomocy technicznej).