2012-12-28 58 views
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。尽管如此,我还是有点困惑,难道不应该使用我上面尝试的方法吗?

回答

5

我终于找到了问题,当然这是一个用户问题。首先,当我在Azure门户时,我没有找到要上传证书的地方,所以我上传了第一个提到证书的地方。我发现的是这个区域是错误的,我将证书上传到我想管理的云服务下的证书区域,这是错误的地方。

将证书上传到正确的地方是在蔚蓝的管理门户settings下。所以如果证书上传到正确的位置,上面的代码就可以工作。