ARM模板resourceid()函数失败

时间:2019-12-16 00:55:37

标签: azure arm-template

请在这里帮助我了解我的Azure ARM模板到底有什么问题,这是非常基本的,需要一些输入参数并打印出resourceId。

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "virtualNetworkName": {
      "type": "string"
    },
    "virtualNetworkResourceGroupName": {
      "type": "string"
    },
    "subnetName": {
      "type": "string"
    },
    "location": {
      "type": "string",
      "metadata": {
        "description": "Location to Deploy Azure Resources"
      }
    }
  },
  "resources": [],
  "outputs": {
    "subnetRef": {
      "type": "string",
      "value": "[resourceId(parameters('virtualNetworkResourceGroupName'), 'Microsoft.Network/virtualNetworks/subnets', parameters('virtualNetworkName'), parameters('subnetName'))]"
    }
  }
}

提供必需的参数,它将失败,并显示以下错误消息。

参数文件

{  
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "virtualNetworkName": {
      "value": "core-services-vnet"
    },
    "virtualNetworkResourceGroupName": {
      "value": "core-networking-rg"
    },
    "subnetName": {
      "value": "private"
    },
    "location": {
      "value": "westus"
    }
  }
}
$ az deployment create -n core-deploy --template-file azuredeploy.json --parameters @params.json --location westus

Deployment failed. Correlation ID: b97a7544-2814-40c0-88c9-fbaaea2bf645. The template output 'subnetRef' is not valid: The provided value 'core-networking-rg' is not valid subscription identifier. Please see https://aka.ms/arm-template-expressions/#resourceid for usage details.

我在这里想念什么?

谢谢,g

1 个答案:

答案 0 :(得分:0)

问题是deployment scope。您可以将部署定向到Azure订阅或订阅中的资源组。

在模板中,$ schema library(tidyr) my_df_from_bq %>% unnest_wider(chances, names_sep = "_") %>% unnest_wider(dribbles, names_sep = "_") # season o_or_d chances_num_ato… chances_ato_pts… chances_ato_ppp chances_num_ato… # <chr> <chr> <int> <int> <dbl> <dbl> #1 2019 Offen… 6 4 0.667 0.273 #2 2019 Defen… 7 2 0.286 0.535 #3 2017 Offen… 5 2 0.4 0.147 #4 2018 Offen… 1 0 0 0 #5 2018 Defen… 6 8 1.33 0.701 # … with 3 more variables: chances_ato_ppp_pctile <dbl>, dribbles_dribbles <int>, # dribbles_dribbles_pctile <dbl> 用于资源组部署,而您使用的命令https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#用于订阅级部署。订阅级部署的模式az deployment create与资源组部署的模式不同。您可以从creating resource groups and resources at the subscription level获得参考。

在这种情况下,可以使用命令https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#代替az group deployment create -n core-deploy --template-file azuredeploy.json --parameters @params.json --location westus来解决此问题。