4
我想通过PowerShell将我的应用程序部署到Azure。到目前为止,我已经在localmachine商店中创建了一个证书,我不打算像我一样运行部署脚本,将脚本上传到azure。下一步是在PowerShell中访问Azure上的服务,但在那里失败。剧本我至今是:如何使用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文件并导入之后,我确实得到了它,而不是尝试使用Set-AzureSubscription
。尽管如此,我还是有点困惑,难道不应该使用我上面尝试的方法吗?