我想使用 powershell 将我的应用程序部署到天蓝色。到目前为止,我已经在本地机器存储中创建了一个证书,我不会像我一样运行部署脚本,将脚本上传到天蓝色。下一步是在 powershell 中访问 azure 上的服务,但它失败了。我到目前为止的脚本是:
$cert = Get-Item Cert:\LocalMachine\deploy\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Set-AzureSubscription -SubscriptionName $subscriptionName -SubscriptionId $subscriptionId -Certificate $cert
Select-AzureSubscription $subscriptionName
$service = Get-AzureService $azureId
它在最后一行失败,并显示以下消息:
Get-AzureService : Communication could not be established. This could be due to an invalid subscription ID. Note that subscription IDs are case sensitive.
At F:\DeployTest\deploy.ps1:9 char:12
+ $service = Get-AzureService $azureId
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-AzureService], Exception
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Management.ServiceManagement.HostedServices.GetAzureServiceCommand
Get-AzureService : HTTP Status Code: AuthenticationFailed - HTTP Error Message: The server failed to authenticate the request. Verify that the certificate is valid and is associated with this subscription.
Operation ID:
At F:\DeployTest\deploy.ps1:9 char:12
+ $service = Get-AzureService $azureId
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzureService], CommunicationException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Management.ServiceManagement.HostedServices.GetAzureServiceCommand
我真的不知道问题是什么,我正在尝试使用的证书已上传,所以感觉就像我错过了一些基本的东西。
更新:在下载 .publishsettings 文件并导入它而不是尝试使用 .publishsettings 文件后,我确实让它工作了Set-AzureSubscription
。不过我还是有点迷茫,难道不能用我上面试过的方法吗?