在参数文件中获取当前订阅 ID [英] Get current subscription id in parameter file

查看:26
本文介绍了在参数文件中获取当前订阅 ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样一个 azuredeploy.parameters.json 文件:

I have such a azuredeploy.parameters.json file:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "adminLogin": {
      "value": "exampleadmin"
    },
    "adminPassword": {
      "reference": {
        "keyVault": {
          "id": "/subscriptions/[subscription().subscriptionId]/resourceGroups/ARMTemplate/providers/Microsoft.KeyVault/vaults/dev-kv"

        },
        "secretName": "ExamplePassword"
      }
    },
    "sqlServerName": {
      "value": "TestServer"
    }

  }
}

我的目标是提取当前的 subscriptionId 并将其集成到 id 中.是否可以在参数文件中完成这项工作?

My aim is to extract the current subscriptionId and integrate it into the id. Is it possible in parameter file to do this job?

推荐答案

如果有效,正确的语法是:

if it works, the correct syntax would be:

"id": "[concat(subscription().id, '/resourceGroups/ARMTemplate/providers/Microsoft.KeyVault/vaults/dev-kv')]"

如果它不起作用,您可以使用嵌套部署将其作为参数传递给嵌套部署并从中返回值,或者只是在嵌套部署中执行您的内容

if it doesnt work you can use a nested deployment to pass it as an argument to a nested deployment and return the value from it or just execute your stuff in a nested deployment

这篇关于在参数文件中获取当前订阅 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆