[英]Get public IP address of API Management from ARM template
I got this API Management ARM template 我得到了这个API Management ARM模板
{
"apiVersion": "2017-03-01",
"name": "[variables('am-apimanagement-service-name')]",
"type": "Microsoft.ApiManagement/service",
"location": "North Europe",
"sku": {
"name": "[parameters('am-sku')]",
"capacity": "[parameters('am-skuCount')]"
},
"properties": {
"publisherEmail": "[parameters('am-publisher-email-p')]",
"publisherName": "[parameters('am-publisher-name-p')]"
},
"resources": [
{
"type": "apis",
"apiVersion": "2017-03-01",
"name": "test",
"dependsOn": [
"[concat('Microsoft.ApiManagement/service/',variables('am-apimanagement-service-name'))]"
],
"properties": {
"displayName": "test",
"description": "",
"serviceUrl": "[concat('https://test-',parameters('environment'),'.azurewebsites.net')]",
"path": "test",
"protocols": [
"https"
],
"isCurrent": true
},
"resources": [
{
"apiVersion": "2017-03-01",
"type": "operations",
"name": "GetTEst",
"dependsOn": [
"[concat('Microsoft.ApiManagement/service/', variables('am-apimanagement-service-name'), '/apis/test')]"
],
"properties": {
"displayName": "GET",
"method": "GET",
"urlTemplate": "/api/sites",
"description": "Get"
}
}
]
}
]
}
And this Web API ARM template 还有这个Web API ARM模板
{
"apiVersion": "2016-03-01",
"name": "[variables('swa-name')]",
"type": "Microsoft.Web/sites",
"properties": {
"name": "[variables('swa-name')]",
"serverFarmId": "[variables('swa-hosting-plan-name')]",
"hostingEnvironment": "[parameters('swa-hosting-environment')]",
"siteConfig": {
"appSettings": [
{
"name": "Test:ConnectionString",
"value": "[concat('Server=tcp:', reference(resourceId('Microsoft.Sql/servers/', variables('db-serverName'))).fullyQualifiedDomainName, ',1433;Initial Catalog=', variables('db-databaseName'), ';Persist Security Info=False;User ID=', parameters('db-administratorLogin'), ';Password=', parameters('db-administratorLoginPassword'), ';MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;')]"
}
],
"ipSecurityRestrictions": [
{
"ipAddress": "[variables('test-ip-address')]",
"subnetMask": "255.255.255.255"
}
]
}
},
"location": "[parameters('swa-location')]",
"tags": {
},
"kind": "api",
"dependsOn": [
"[concat('Microsoft.Web/serverfarms/', variables('swa-hosting-plan-name'))]"
]
}
How do I use the reference function to get IP address of the API Management resource from the Web API ? 如何使用引用函数从Web API获取API管理资源的IP地址? I want to put the API Management IP address in the ipSecurityRestrictions.
我想将API管理IP地址放在ipSecurityRestrictions中。 I can not figure it out, and it is frustrating me quite a bit.
我无法弄清楚,这让我很沮丧。
I have tried this from the web api resource resource section of the ARM template: 我已经从ARM模板的Web api资源资源部分进行了尝试:
"ipSecurityRestrictions": [
{
"ipAddress": "[variables('test-ip-address')]",
"subnetMask": "255.255.255.255"
},
{
"ipAddress": "[reference(variables('am-apimanagement-service-name')).publicIPAddresses[0]]",
"subnetMask": "255.255.255.255"
}
]
But it doesnt work. 但它不起作用。 Maybe I am not able to get the IP address in this step of the process?
也许我无法在此步骤中获取IP地址? I am reading about outputs and linked templates.
我正在阅读有关输出和链接模板的信息。 Maybe this is the solution?
也许这是解决方案?
I think you should add the api version to your reference, as the API management is not deployed in the same template as where you're refering to it. 我认为您应该将api版本添加到引用中,因为API管理未与引用位置部署在同一模板中。
https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-template-functions-resource#reference https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-template-functions-resource#reference
Something like this 像这样
{
"ipAddress": "[reference(variables('am-apimanagement-service-name'), '2017-03-01').publicIPAddresses[0]]",
"subnetMask": "255.255.255.255"
}
The crazy thing here is that I need two things: 疯狂的事情是我需要两件事:
The thing is that a free tier API Management resource is actually not assigned a static IP, but a dynamic ip. 问题是,免费层API管理资源实际上没有分配静态IP,而是动态IP。 Still the static ip address is assigned to the staticIp property of the referenced object:
仍然将静态IP地址分配给所引用对象的staticIp属性:
"ipAddress": "[reference(variables('am-apimanagement-service-name'),'2017-03-01').staticIps[0]]"
This will reference the IP correctly. 这将正确引用IP。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.