如何在Azure二头肌部署模板中获取Linux App服务的主机URL
我使用下面显示的二头肌资源创建了一个应用程序服务,
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 IE var fnappurl = fnapp.url
或类似的东西?
tia
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通过配置
extensions.http.routeprefix
inhost.json
,没有针对此基本路径的特定属性。(文档: https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-bindings-http-webhook?tabs=in-process%2cfunctionsv2&pivots; pivots; pivots hostjson-settings )
如果
/api
前缀是不需要,那么使用二头肌文件中的以下输出就足够了:然后在
host.json
中确保将RoutePrefix设置为一个空字符串:如果您想使用路由前缀,您需要将其与默认主机名相结合:
There is no specific property for this base path as it is set by configuring the value of
extensions.http.routePrefix
inhost.json
.(Docs: https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-http-webhook?tabs=in-process%2Cfunctionsv2&pivots=programming-language-csharp#hostjson-settings)
If the
/api
prefix is not required, then it would suffice to use the following output in your Bicep file:Then in your
host.json
ensure the routePrefix is set to an empty string:If you do want to use a route prefix, you need to combine it with the default host name:
据我所知,您无法从功能中获得直接URL。但是您可以使用以下内容:
output functionbaseurl string ='https:// $ {function.properties.defaulthostname}/api'
这将导致默认主机名,包括“ azurewebersites.net” part。
在
template.bicep
中查看完整示例:As far as I know, there is no direct url you can get from the function. But you can use something like:
output functionBaseUrl string = 'https://${function.properties.defaultHostName}/api'
This will result in the default hostname including the "azurewebsites.net" part.
Check the full example in the
template.bicep
here:https://github.com/DSpirit/azure-functions-bicep-outputs-host