簡體   English   中英

ARM模板中的Azure訂閱名稱

[英]Azure subscription name in ARM template

我正在嘗試使用以下模板在ARM模板中獲取Azure訂閱名稱

{
  "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {  },
  "variables": {
    "subscriptionName": "[subscription().displayName]"
  },
  "resources": [  ],
  "outputs": {
    "exampleOutput": {
        "value": "[variables('subscriptionName')]",
        "type" : "object"
    }
  }
}

使用以下powershell命令在模板上運行

New-AzureRmResourceGroupDeployment -Name MyTest -ResourceGroupName EnvDev -TemplateFile C:\\Users\\xyz\\test.json

但是出現以下錯誤

New-AzureRmResourceGroupDeployment : 2:04:11 PM - {
"code": "DeploymentOutputEvaluationFailed",
"message": "Unable to evaluate template outputs: 'exampleOutput'. Please see error details and deployment operations. Please see https://aka.ms/arm-debug for usage details.",
"details": [
 {
  "code": "DeploymentOutputEvaluationFailed",
  "target": "exampleOutput",
  "message": "The template output 'exampleOutput' is not valid: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.."
 }
]}
At line:1 char:1
+ New-AzureRmResourceGroupDeployment -Name SentienceTest -ResourceGroup ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet

如何在ARM模板中獲取訂閱名稱,在該模板下部署訂閱?

有人知道這是怎么了嗎?

考慮到操作錯誤,建議您嘗試以下操作:

  "outputs": {
    "exampleOutput": {
        "value": "[variables('subscriptionName')]",
        "type" : "string"
    }
  }

因此,將“類型”更改為字符串。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM