我想用PowerShell将我的应用程序部署到azure.到目前为止,我已在localmachine商店中创建了一个证书,我不会像我一样运行部署脚本,将脚本上传到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
Run Code Online (Sandbox Code Playgroud)
它在最后一行失败,并显示以下消息:
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
Run Code Online (Sandbox Code Playgroud)
我真的不知道问题是什么,我试图使用的证书被上传,所以感觉有一些基本的我错过了.
更新:我在下载.publishsettings文件并导入而不是尝试使用后确实让它工作Set-AzureSubscription.我仍然有点困惑,不应该可以使用我上面尝试的方法吗?
我终于找到了问题,当然这是一个用户问题.首先,当我在天蓝色的门户网站时,我没有找到上传证书的位置,因此我将其上传到第一个位置,我发现提到了证书.我发现的是这个区域是错误的,我将证书上传到我想管理的云服务下的证书区域,这是错误的地方.
上传证书的正确位置settings位于azure的管理门户中.因此,如果证书上传到正确的位置,上面的代码就可以工作.
| 归档时间: |
|
| 查看次数: |
4660 次 |
| 最近记录: |