使用 powershell 部署 ARM 模板:即使已定义,也要求提供 subscriptionID
Deploying ARM templates using powershell: asking for subscriptionID even when it is defined
我正在尝试使用 ARM 模板和之前从 Azure 下载的 "deploy.ps1" 脚本(使用门户)在 Azure 上部署服务。
"deploy.ps1" 文件中有一个部分,您可以在其中指定订阅 ID、资源组等:
param(
[Parameter(Mandatory=$True)]
[string]
$subscriptionId = "ID",
[Parameter(Mandatory=$True)]
[string]
$resourceGroupName = "Name"
......
$templateFilePath = "template.json",
[string]
$parametersFilePath = "parameters.json"
)
即使定义了 SubscriptionID,当我执行 "deploy.ps1" 脚本时,系统仍然要求提供订阅 ID:
cmdlet deploy.ps1 at command pipeline position 1
Supply values for the following parameters:
subscriptionId:
你能帮我解决这个问题吗?
在这种情况下,错误是由于 powershell 脚本将一些参数定义为 Mandatory
并且您不能为强制参数分配默认值(如@Tomalak 所暗示的)。
我正在尝试使用 ARM 模板和之前从 Azure 下载的 "deploy.ps1" 脚本(使用门户)在 Azure 上部署服务。 "deploy.ps1" 文件中有一个部分,您可以在其中指定订阅 ID、资源组等:
param(
[Parameter(Mandatory=$True)]
[string]
$subscriptionId = "ID",
[Parameter(Mandatory=$True)]
[string]
$resourceGroupName = "Name"
......
$templateFilePath = "template.json",
[string]
$parametersFilePath = "parameters.json"
)
即使定义了 SubscriptionID,当我执行 "deploy.ps1" 脚本时,系统仍然要求提供订阅 ID:
cmdlet deploy.ps1 at command pipeline position 1
Supply values for the following parameters:
subscriptionId:
你能帮我解决这个问题吗?
在这种情况下,错误是由于 powershell 脚本将一些参数定义为 Mandatory
并且您不能为强制参数分配默认值(如@Tomalak 所暗示的)。