gpt4 book ai didi

azure - 如何在 ARM 模板输出中获取 Azure VM 的 FQDN

转载 作者:行者123 更新时间:2023-12-02 06:20:04 25 4
gpt4 key购买 nike

以下是我创建公共(public)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')]"
}

关于azure - 如何在 ARM 模板输出中获取 Azure VM 的 FQDN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52116095/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com