当前位置 : 主页 > 编程语言 > 其它开发 >

【Azure 应用服务】App Service 开启了私有终结点(Private Endpoint)模式后,如何来实现

来源:互联网 收集:自由互联 发布时间:2022-06-23
问题描述 因为中国区的App Service对外(公网访问)需要进行ICP备案,所以很多情况下,Web应用部署到App Service后,都是通过Application Gateway(应用程序网关)来对外网暴露,提供公网访问。 上
问题描述

因为中国区的App Service对外(公网访问)需要进行ICP备案,所以很多情况下,Web应用部署到App Service后,都是通过Application Gateway(应用程序网关)来对外网暴露,提供公网访问。

上图列出了使用Application Gateway后,外网访问App Service的示意图。 如果直接访问,则会出现403的错误页面。

那么,在这样的情况下,我们如何来实现通过公网暴露Git的URI,实现外网成功部署App Service的代码呢?

 

问题解答

当然,可以通过Application Gateway 来暴露 App Service默认的GIT Repository 地址 :https://<appservicename>.scm.chinacloudsites.cn:443/<appservicename>.git

如何配置Application Gateway 与App Service的服务,参考官方文档:使用应用程序网关配置应用服务(https://docs.azure.cn/zh-cn/application-gateway/configure-web-app?tabs=customdomain%2Cazure-portal)

 

在配置的过程中,必须注意以下三点:

第一点:为Application Gateway  配置自定义域名 (本次实验中只是短暂使用,所以使用公网IP地址进行解析

 

第二点:App Gateway 的后端池(Backend Pool) 不能直接选择App Service,需要选择 IP Address or FQDN,并输入SCM的域名。 如: <appservicename>.scm.chinacloudsites.cn

 

第三点:为App Gateway配置自定义健康探测(Health Probes),  Host 为SCM域名(<appservicename>.scm.chinacloudsites.cn), Path 可以指向 /<appservicename>.git  或者是SCM的跟目录 / 。

由于SCM站点的访问时需要认证的,App Gateway发出的探测结果都是401 - Unauthorized 。所以就必须接受401是一个正确的探测结果才行。

 

以上三点配置完成后,可以回到Application Gateway的Backend Health页面,查看后端池的健康状态,只有当后端池状态为Health时,才能成功访问到后端,否则这会得到502页面。

如果第三步中没有配置 401为一个匹配的返回状态,则 Backend Health的结果显示为:

Received invalid status code: 401 in the backend server’s HTTP response. As per the health probe configuration, 200-399 is the acceptable status code. Either modify probe configuration or resolve backend issues.

 

当Application Gateway设置完成后,开始Local Git的部署验证:

首先,复制出App Service Local Git Repository 的地址,把 HTTPS 改为 HTTP, 并用 Application Gateway的IP地址代替域名

然后,使用 git clone http://<ip address>/<appservicename>.git,获取原始库中代码

最后,使用 git commit / git push / git remote -v 

Clone/Push截图:

 

 

参考资料

使用应用程序网关配置应用服务:https://docs.azure.cn/zh-cn/application-gateway/configure-web-app?tabs=customdomain%2Cazure-portal

从本地 Git 部署到 Azure 应用服务:https://docs.azure.cn/zh-cn/app-service/deploy-local-git?tabs=cli#prerequisites

 

[END]

 

当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!

上一篇:C/C++实现合成地震记录
下一篇:没有了
网友评论