J. *_*ews 6 azure azure-api-management azure-web-app-service azure-devops azure-bicep
我使用如下所示的二头肌资源创建了一个应用程序服务
name: '${appName}'
location: location
kind: 'linux,container,fnapp'
properties: {
serverFarmId: servicePlan.id
siteConfig: {
linuxFxVersion: 'DOCKER|${dockerLocation}'
healthCheckPath: '/api/healthcheck'
alwaysOn: true
appSettings: [
...
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
它按预期工作,但是我想获取该应用程序服务的 url,以用作我的 apim 服务的后端 url。
我目前正在使用var fnAppUrl = 'https://${fnApp.name}.azurewebsites.net/api'. 有什么方法可以从函数应用程序资源的直接输出(即var fnAppUrl = fnApp.url或类似的东西)中获取默认网址?
TIA
此基本路径没有特定属性,因为它是通过配置extensions.http.routePrefixin的值来设置的 host.json。(文档: https: //learn.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}'
Run Code Online (Sandbox Code Playgroud)
然后确保host.json将routePrefix 设置为空字符串:
resource myFunctionApp 'Microsoft.Web/sites@2021-03-01' = {
// ...
}
output functionBaseUrl string = 'https://${myFunctionApp.properties.defaultHostName}'
Run Code Online (Sandbox Code Playgroud)
如果您确实想使用路由前缀,则需要将其与默认主机名结合起来:
resource myFunctionApp 'Microsoft.Web/sites@2021-03-01' = {
// ...
}
output functionBaseUrl string = 'https://${myFunctionApp.properties.defaultHostName}/api'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2370 次 |
| 最近记录: |