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

本文涉及的产品
.cn 域名,1个 12个月
简介: 【Azure 应用服务】App Service 开启了私有终结点(Private Endpoint)模式后,如何来实现公网Git部署呢?

问题描述

因为中国区的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]

相关文章
|
23天前
|
IDE 网络安全 开发工具
【Azure App Service】Local Git App Service的仓库代码遇见卡住不Clone代码的问题
【Azure App Service】Local Git App Service的仓库代码遇见卡住不Clone代码的问题
【Azure App Service】Local Git App Service的仓库代码遇见卡住不Clone代码的问题
|
23天前
|
安全 Java 应用服务中间件
【Azure 应用服务】App Service 默认页面暴露Tomcat版本信息,存在安全风险
【Azure 应用服务】App Service 默认页面暴露Tomcat版本信息,存在安全风险
|
23天前
|
应用服务中间件 Linux 网络安全
【Azure 应用服务】App Service for Linux 环境中为Tomcat页面修改默认的Azure 404页面
【Azure 应用服务】App Service for Linux 环境中为Tomcat页面修改默认的Azure 404页面
|
23天前
|
开发工具 git
【Azure App Service】App Service设置访问限制后,使用git clone代码库出现403报错
【Azure App Service】App Service设置访问限制后,使用git clone代码库出现403报错
|
23天前
|
存储 Linux 开发工具
【Azure App Service】本地Git部署Python Flask应用上云(Azure App Service For Linux)关键错误
【Azure App Service】本地Git部署Python Flask应用上云(Azure App Service For Linux)关键错误
|
23天前
|
Docker 容器
【Azure 应用服务】App Service for Container 无法拉取Docker Hub中的镜像替代方案
【Azure 应用服务】App Service for Container 无法拉取Docker Hub中的镜像替代方案
|
23天前
|
API C++
【Azure 应用服务】Azure Function App在部署时候遇见 503 ServiceUnavailable
【Azure 应用服务】Azure Function App在部署时候遇见 503 ServiceUnavailable
|
23天前
|
网络协议
【Azure 应用服务】Azure Data Factory中调用Function App遇见403 - Forbidden
【Azure 应用服务】Azure Data Factory中调用Function App遇见403 - Forbidden
|
23天前
|
API
【Azure 应用服务】当在Azure App Service的门户上 Log Stream 日志无输出,需要如何操作让其输出Application Logs呢?
【Azure 应用服务】当在Azure App Service的门户上 Log Stream 日志无输出,需要如何操作让其输出Application Logs呢?
|
23天前
|
Kubernetes Linux Docker
【Azure 应用服务】使用Docker Compose创建App Service遇见"Linux Version is too long. It cannot be more than 4000 characters"错误
【Azure 应用服务】使用Docker Compose创建App Service遇见"Linux Version is too long. It cannot be more than 4000 characters"错误