将Azure App Service部署从ACR容器改为Bitbucket仓库CI部署
问题
此前通过Bitbucket Pipeline构建Docker镜像并推送到Azure Container Registry(ACR),再通过ACR实现Azure App Service的持续部署。现希望跳过Docker环节,直接将Bitbucket与App Service集成。
执行以下Azure CLI命令配置部署源:
az webapp deployment source config --name <name> --resource-group <group> --repo-url https://bitbucket.org/<repo> --branch <branch> --git-token <token> --verbose
尽管URL和git-token配置正确,仍出现错误:
location is not a known attribute of class <class 'azure.mgmt.web.v2023_01_01.models._models_py3.SourceControl'> and will be ignored source_control_name is not a known attribute of class <class 'azure.mgmt.web.v2023_01_01.models._models_py3.SourceControl'> and will be ignored location is not a known attribute of class <class 'azure.mgmt.web.v2023_01_01.models._models_py3.SiteSourceControl'> and will be ignored Cannot find SourceControlToken with name Bitbucket.
需修改部署设置,让App Service从Bitbucket直接部署,而非继续使用ACR镜像。
解决方案
1. 核心问题分析
错误信息中Cannot find SourceControlToken with name Bitbucket是关键:默认情况下Azure尝试通过OAuth自动集成Bitbucket,会查找预配置的Bitbucket源控制令牌,但你使用的是个人访问令牌(PAT),无需自动集成流程。
2. 修正配置命令
在原命令中添加--manual-integration参数,告知Azure使用手动集成模式,直接通过提供的PAT访问Bitbucket仓库:
az webapp deployment source config --name <name> --resource-group <group> --repo-url https://bitbucket.org/<repo> --branch <branch> --git-token <token> --manual-integration --verbose
3. 清理原有ACR部署配置(可选)
如果App Service仍保留原有ACR部署的关联配置,可先删除旧部署源:
az webapp deployment source delete --name <name> --resource-group <group>
执行完成后再重新运行修正后的部署源配置命令。
4. 关于警告信息的说明
命令输出中的location、source_control_name相关警告是CLI版本与Azure Web App API版本不匹配导致的冗余提示,不影响部署功能,可忽略。
内容的提问来源于stack exchange,提问作者Srikrishna Balasubramanian
相关产品推荐
相关产品推荐

