我正在使用此 ARM 模板将外部 Azure 函数(已在其他模板中定义)添加到我的 API 管理中,但收到验证错误(资源未在模板中定义)。是否有任何解决方案可以通过 API 管理自动映射 azure 函数?
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {...},
"resources": [
{
"apiVersion": "2017-03-01",
"name": "[parameters('apiManagementServiceName')]",
"type": "Microsoft.ApiManagement/service",
"location": "[parameters('location')]",
"tags": {},
"sku": {
"name": "[parameters('sku')]",
"capacity": "[parameters('skuCount')]"
},
"properties": {
"publisherEmail": "[parameters('publisherEmail')]",
"publisherName": "[parameters('publisherName')]"
}
},
{
"type": "Microsoft.ApiManagement/service/apis",
"apiVersion": "2018-06-01-preview",
"name": "[concat(parameters('apiManagementServiceName'), '/', parameters('indexerApp'))]",
"dependsOn": [
"[resourceId('Microsoft.ApiManagement/service', parameters('apiManagementServiceName'))]",
"[resourceId(resourceGroup().name, 'Microsoft.Web/sites', parameters('indexerApp'))]"
],
"properties": {
"displayName": "[parameters('indexerApp')]",
"apiRevision": "1",
"description": "Import from \"[parameters('indexerApp')]\" Function App",
"path": "[parameters('indexerApp')]",
"protocols": [
"https"
]
}
}
]
}
最佳答案
直接链接到逻辑应用程序、函数或其他内部 Azure 资源的资源是 backends (注意复数):
{
"name": "string",
"type": "Microsoft.ApiManagement/service/backends",
"apiVersion": "2019-01-01",
"properties": {
"title": "string",
"description": "string",
"resourceId": "string",
"properties": {
"serviceFabricCluster": {
"clientCertificatethumbprint": "string",
"maxPartitionResolutionRetries": "integer",
"managementEndpoints": [
"string"
],
"serverCertificateThumbprints": [
"string"
],
"serverX509Names": [
{
"name": "string",
"issuerCertificateThumbprint": "string"
}
]
}
},
"credentials": {
"certificate": [
"string"
],
"query": {},
"header": {},
"authorization": {
"scheme": "string",
"parameter": "string"
}
},
"proxy": {
"url": "string",
"username": "string",
"password": "string"
},
"tls": {
"validateCertificateChain": "boolean",
"validateCertificateName": "boolean"
},
"url": "string",
"protocol": "string"
}
}
我相信,如果您指定resourceId
属性,Azure基础设施会自动将其他属性连接到您的函数(或逻辑应用)。 “id”的格式并不明显,它需要一个管理URI,其格式为mentioned in this documentation
然后,您可以使用操作的策略将这个创建的后端链接到一个操作 - 这在 ARM 模板中表达起来很困难,但它应该包含一个策略表达式:
<set-backend-service backend-id=\"[name of your backend]\"/>
有关如何将它们链接在一起的示例可以在 this linked sample 中找到。 。它以 Service Fabric 为特色,但它也应该普遍适用于函数。
关于azure - 如何使用 ARM 模板将 azure 函数添加到 API 管理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60147438/