gpt4 book ai didi

powershell - 如何使用powershell部署到Azure?

转载 作者:行者123 更新时间:2023-12-01 10:34:58 26 4
gpt4 key购买 nike

我想使用 powershell 将我的应用程序部署到 azure。到目前为止,我已经在本地计算机存储中创建了一个证书,我不会像我一样运行部署脚本,将脚本上传到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。不过我还是有点困惑,难道不能使用我上面尝试过的方法吗?

最佳答案

终于找到问题了,当然是用户问题。首先,当我在 azure 门户中时,我找不到上传证书的位置,因此我将其上传到我发现的第一个提到证书的位置。我发现这个区域是错误的,我将证书上传到我要管理的云服务下的证书区域,这是错误的地方。

上传证书的正确位置位于 azure 管理门户的设置下。因此,如果证书上传到正确的位置,上面的代码就可以工作。

关于powershell - 如何使用powershell部署到Azure?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14069593/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com