如何输出通过ARM模板部署的应用服务的IP地址
How to output the IP address of an App Service deployed via ARM Template
我想要从 ARM 模板部署的应用服务的 public IP 地址,如下面的简化模板。我看过从 API 网关、VM 的 VNET、应用服务环境等获取 public 入站 IP 地址的示例,但我还没有找到任何指示如何获取它的内容从一个简单的应用程序服务部署。我发现导航 ARM API,以及如何将字符串转换为 JSON 文件,而不是拜占庭式。如有任何帮助,我们将不胜感激。
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appServiceName": {
"type": "string",
"minLength": 1,
"metadata": {
"description": "Specifies the name of the Azure App Service"
}
},
"appServicePlanName": {
"type": "string",
"minLength": 1
}
},
"variables": {
},
"resources": [
{
"apiVersion": "2015-08-01",
"name": "[parameters('appServiceName')]",
"type": "Microsoft.Web/sites",
"kind": "app",
"location": "[resourceGroup().location]",
"dependsOn": [],
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName'))]",
"clientAffinityEnabled": false
},
"resources": [],
}
],
"outputs": {
"appServiceName": {
"type": "string",
"value": "[parameters('appServiceName')]"
},
"ipAddress": {
"type": "string",
"value": "whatingodsnamegoeshere"
}
}
}
您需要使用 reference()
函数并为其提供资源 ID,如果资源在同一模板中,则仅提供名称:
reference(parameters('appServiceName'), '2016-03-01', 'Full').properties.inboundIpAddress
或 resourceId()
:
reference(resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName')), '2016-03-01', 'Full').properties.inboundIpAddress
我想要从 ARM 模板部署的应用服务的 public IP 地址,如下面的简化模板。我看过从 API 网关、VM 的 VNET、应用服务环境等获取 public 入站 IP 地址的示例,但我还没有找到任何指示如何获取它的内容从一个简单的应用程序服务部署。我发现导航 ARM API,以及如何将字符串转换为 JSON 文件,而不是拜占庭式。如有任何帮助,我们将不胜感激。
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appServiceName": {
"type": "string",
"minLength": 1,
"metadata": {
"description": "Specifies the name of the Azure App Service"
}
},
"appServicePlanName": {
"type": "string",
"minLength": 1
}
},
"variables": {
},
"resources": [
{
"apiVersion": "2015-08-01",
"name": "[parameters('appServiceName')]",
"type": "Microsoft.Web/sites",
"kind": "app",
"location": "[resourceGroup().location]",
"dependsOn": [],
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName'))]",
"clientAffinityEnabled": false
},
"resources": [],
}
],
"outputs": {
"appServiceName": {
"type": "string",
"value": "[parameters('appServiceName')]"
},
"ipAddress": {
"type": "string",
"value": "whatingodsnamegoeshere"
}
}
}
您需要使用 reference()
函数并为其提供资源 ID,如果资源在同一模板中,则仅提供名称:
reference(parameters('appServiceName'), '2016-03-01', 'Full').properties.inboundIpAddress
或 resourceId()
:
reference(resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName')), '2016-03-01', 'Full').properties.inboundIpAddress