[英]Azure Bicep giving InvalidTemplateDeployment error for Azure App Service Plan deployment
[英]How to get the host url of a linux app service in azure bicep deployment templates
我使用如下所示的二頭肌資源創建了一個應用服務
name: '${appName}'
location: location
kind: 'linux,container,fnapp'
properties: {
serverFarmId: servicePlan.id
siteConfig: {
linuxFxVersion: 'DOCKER|${dockerLocation}'
healthCheckPath: '/api/healthcheck'
alwaysOn: true
appSettings: [
...
]
}
}
}
可以按預期工作,但是我想獲取該應用服務的 url 以用作我的 apim 服務的后端 url。
我目前正在使用var fnAppUrl = 'https://${fnApp.name}.azurewebsites.net/api'
。 有什么方法可以從函數應用資源的直接輸出中獲取默認 url,即var fnAppUrl = fnApp.url
或類似的東西?
TIA
據我所知,您無法從該函數中獲得直接的 url。 但是你可以使用類似的東西:
output functionBaseUrl string = 'https://${function.properties.defaultHostName}/api'
這將導致包含“azurewebsites.net”部分的默認主機名。
在此處查看template.bicep
中的完整示例: https ://github.com/DSpirit/azure-functions-bicep-outputs-host
這個基本路徑沒有特定的屬性,因為它是通過在host.json
中配置extensions.http.routePrefix
的值來設置的。 (文檔: https ://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-http-webhook?tabs=in-process%2Cfunctionsv2&pivots=programming-language-csharp#hostjson-settings)
如果不需要/api
前綴,那么在 Bicep 文件中使用以下輸出就足夠了:
resource myFunctionApp 'Microsoft.Web/sites@2021-03-01' = {
// ...
}
output functionBaseUrl string = 'https://${myFunctionApp.properties.defaultHostName}'
然后在您的host.json
中確保 routePrefix 設置為空字符串:
{
"extensions": {
"http": {
"routePrefix": ""
}
}
}
如果您確實想使用路由前綴,則需要將其與默認主機名結合使用:
resource myFunctionApp 'Microsoft.Web/sites@2021-03-01' = {
// ...
}
output functionBaseUrl string = 'https://${myFunctionApp.properties.defaultHostName}/api'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.