在我的模板输出中,我想返回分配的公共 IP 地址。我在“输出”部分尝试了以下内容:(在“对象”类型的输出中)
"ipobj": "[reference(variables('publicIPAddressName'),'2020-07-01','Full')]"
这有效并返回整个 publicIpAddress 对象:
"ipobj": {
"apiVersion": "2020-07-01",
"location": "eastus",
"sku": {
"name": "Basic",
"tier": "Regional"
},
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "...",
"ipAddress": "...",
"publicIPAddressVersion": "IPv4",
"publicIPAllocationMethod": "Dynamic",
"idleTimeoutInMinutes": 4,
"dnsSettings": {
"domainNameLabel": "simplelinuxvm-zktwk4fzmy5p4",
"fqdn": "simplelinuxvm-zktwk4fzmy5p4.eastus.cloudapp.azure.com"
},
"ipTags": [],
"ipConfiguration": {
"id": "/subscriptions/.../resourceGroups/.../providers/Microsoft.Network/networkInterfaces/simpleLinuxVMNetInt/ipConfigurations/ipconfig1"
}
},
"subscriptionId": "...",
"resourceGroupName": "...",
"scope": "",
"resourceId": "Microsoft.Network/publicIpAddresses/simpleLinuxVMPublicIP",
"referenceApiVersion": "2020-07-01",
"condition": true,
"isConditionTrue": true,
"isTemplateResource": false,
"isAction": false,
"provisioningOperation": "Read"
}
这符合publicIpAddress 对象的 API 文档。而且我还可以使用不带“Full”参数的引用来检索一些属性,根据Azure doc,它应该返回对象的。这些工作:properties
"[reference(variables('publicIPAddressName')).dnsSettings.fqdn]"
"[reference(variables('publicIPAddressName')).publicIPAddressVersion]"
但其他一些属性无法访问:
"[reference(variables('publicIPAddressName')).ipAddress]"
"[reference(variables('publicIPAddressName'),'2020-07-01','Full').properties.ipAddress]"
根据错误消息,(在中间示例的情况下):
The template output '...' is not valid: The language expression property 'ipAddress' doesn't exist, available properties are 'provisioningState, resourceGuid, publicIPAddressVersion, publicIPAllocationMethod, idleTimeoutInMinutes, dnsSettings, ipTags'
因此,Azure 似乎不允许我访问完整输出中存在的属性。这背后是否有任何解释/意图,或者至少有解决方法?
注意:如果我将“字符串”输出(即不是对象的一部分)定义为
"ip": {
"type": "string",
"value": "[reference(variables('publicIPAddressName')).ipAddress]"
}
或者
"ip": {
"type": "string",
"value": "[reference(variables('publicIPAddressName'),'2020-07-01','Full').properties.ipAddress]"
},