【Azure 应用服务】App Service 配置 Application Settings 访问Storage Account得到 could not be resolved: '*.file.core.windows.net'的报错。没有解析成对应中国区 Storage Account地址 *.file.core.chinacloudapi.cn

问题描述

App Service 配置 Application Settings 访问Storage Account。如下:

 {
    "name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
    "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',parameters('storageName'),';AccountKey=',listKeys(variables('storageResourceId'), '2015-05-01-preview').key1)]"
 }

得到 Could not be resolved: '*.file.core.windows.net'的报错

问题解决

因为应用部署在中国区的App Service上,访问的Storage Account也是中国区的资源,所以如果Host 需要为 file.core.chinacloudapi.cn。 而以上的配置方式默认自动后去的是Global获取的Endpoint。中国区的Endpoint需要加上EndpointSuffix。有两种配置方式:

方式一:直接写EndpointSuffix=core.chinacloudapi.cn

[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';EndpointSuffix=core.chinacloudapi.cn', ';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2019-06-01').keys[0].value)]

 

方式二:使用 EndpointSuffix=environment().suffixes.storage

[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';EndpointSuffix=', environment().suffixes.storage, ';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2019-06-01').keys[0].value)]

 

 

 

参考资料

Environment() [This function returns properties for the current Azure environment.]https://docs.azure.cn/en-us/azure-resource-manager/templates/template-functions-deployment?tabs=json#environment

 

posted @   路边两盏灯  阅读(170)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示