gpt4 book ai didi

powershell - VSTS Azure powershell : No default subscription has been designated

转载 作者:行者123 更新时间:2023-12-04 01:17:57 26 4
gpt4 key购买 nike

我正在尝试使用 Azure 资源管理器运行一些 azure powershell 命令,作为我的 Visual Studio Team Services 构建的一部分。

它给了我以下错误:

未指定默认订阅。使用 Select-AzureSubscription -Default 设置默认订阅。

VSTS azure powershell error

我尝试运行的命令:

$website = Get-AzureWebsite | where {$_.Name -eq 'my-website'}
Write-Output ("##vso[task.setvariable variable=DeployUrl;]$website.HostNames")

当我尝试在本地运行它时,我必须调用

Add-AzureAccount
Select-AzureRmSubscription -SubscriptionName "Visual Studio Premium with MSDN"

使其正常工作,但在 VSTS 构建中这是不可能的。

更新:

我已将其配置为使用 azure 经典模式而不是资源管理器,它可以正常工作。我认为这不是一个可行的生产解决方案,因为 azure 经典模式已经过时了。

最佳答案

由于您使用的是 Azure 资源管理器,请检查以下内容:

  1. 确保正确添加“Azure 资源管理器”服务端点。
  2. 正如 bmoore 提到的那样,使用“Get-AzureRmWebApp”命令而不是“Get-AzureWebsite”命令。

我已经在我身边测试过了,它工作正常。

我的 PowerShell 脚本:

$website = Get-AzureRmWebApp | where {$_.Name -eq 'eddieapp0930'}
Write-Host $website.HostNames

从“Azure PowerShell 脚本”任务运行: enter image description here

关于powershell - VSTS Azure powershell : No default subscription has been designated,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39772118/

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