azure - 如何在 ARM 模板输出中获取 Azure VM 的 FQDN
问题描述
以下是我创建公共 IP 地址的模板。现在我想为 PublicIPAddress 获取 fqdn 的输出。
"name": "[variables('publicIPAddressName')]",
"type": "Microsoft.Network/publicIpAddresses",
"apiVersion": "2018-06-01",
"location": "eastus",
"properties": {
"publicIpAllocationMethod": "Static",
"dnsSettings": {
"domainNameLabel": "mycompany"
}
}
"outputs": {
"fqdn": {
"type": "string",
"value": "[if(equals(parameters('serverName'), 'app'), reference(resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))).dnsSettings.fqdn, json(null))]"
}
}
当我部署上述模板时,我看到以下错误
"message": "{\r\n \"error\": {\r\n \"code\": \"InvalidTemplate\",\r\n \"message\": \"Deployment template validation failed: 'The template output 'fqdn' at line '259' and column '13' is not valid: Unable to parse language expression 'if(equals(parameters('serverName'), 'paxata'), reference(variables('publicIPAddressName')).dnsSettings.fqdn, json(null))': expected token 'LeftParenthesis' and actual 'RightParenthesis'.. Please see https://aka.ms/arm-template-expressions for usage details.'.\"\r\n }\r\n}"
解决方案
我可以通过更新 fqdn 输出部分中的 else 条件来解决此问题,并且效果很好。
"fqdn": {
"type": "string",
"value": "[if(equals(parameters('server'), 'app'), reference(resourceId('Microsoft.Network/publicIPAddresses', 'publicip3')).dnsSettings.fqdn, 'FQDN not available')]"
}
推荐阅读
- javascript - RoR:接受文件上传和复制粘贴上传
- javascript - “集合之于数组,就像地图之于对象”是什么意思?
- jquery - 降低事件触发的频率
- python - 从网站中提取链接和项目名称并打印这些列表
- jmeter - 响应代码 400,503 有什么影响?如果我的主要关注点是测量 Web 应用程序的加载时间,我们可以忽略这些代码吗?
- python - 使用 pandas to_datetime 版本 0.23.4 获取今天的日期
- ssas - 是否可以从事实表中获取忽略子级值的层次结构父级成员的度量值?
- facebook - 我在哪里知道为什么在 Facebook 上限制我们的应用程序?
- java - 用空格分隔的 9 个唯一数字的正则表达式?
- database - 具有并发读写的一致性数据库