azure - 如何获取Azure ARM模板中的目录租户名称?

标签 azure azure-resource-manager azure-rm-template

我需要在 ARM 模板中使用租户(目录租户)名称(尤其是在创建 Web 应用程序时)。
enter image description here 可以使用 subscription().displayName 获取订阅名称,但是如何获取关联的目录租户名称?
[subscription().tenantId.displayName][subscription().tenantId.Name] 等表达式不起作用,而且我也找不到任何存在网络上此属性的信息。
我不会对其进行硬编码的方式是订阅所有者或帐户管理员可以轻松更改它,这就是为什么我正在寻找一些现有的变量\参数\等

最佳答案

tenantId 现在可用于模板函数。使用订阅函数:subscription()。

尝试以下输出示例以供引用:

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "resources": [],
    "outputs": {
        "subscriptionOutput": {
            "value": "[subscription()]",
            "type" : "object"
        }
    }
}
<小时/>

对于租户 ID:

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "resources": [],
    "outputs": {
        "subscriptionOutput": {
            "value": "[subscription().tenantId]",
            "type" : "object"
        }
    }
}

引用:

https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/template-functions-resource#subscription

关于azure - 如何获取Azure ARM模板中的目录租户名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49229956/

相关文章:

.net - 为 Azure Function App 启用 VNet 集成时出现 "Http2ConnectionException: HTTP/2 error code ' PROTOCOL_ERROR ' (0x1)"错误

azure - 更新作为参数传递给二头肌文件的对象

azure - 用于识别 Azure Log Analytics 可用 SKU 的编程方法

json - azure ARM : Remove invalid characters

Azure ARM 模板将部署者对象 ID 添加到 key 保管库访问策略

php 登录验证返回 500(内部服务器错误)

asp.net-mvc - Power BI 嵌入式问题

Azure Bicep 不会删除存储容器

azure - 错误请求 : The document creation or update failed because of invalid reference

azure - 无法打开 Azure VM 打开端口