我有一个 Azure 管道,它构建一个 asp-net 核心项目并从中构建一个 docker 映像并将其推送到 Azure 容器注册表。
这个管道是由一个azure-pipelines.acr.yml
文件组成的。我对 Deployments 分支执行的每个 git push 操作都会在新构建中将其转换到我的管道中。
直到这里,我有一个 CI 管道,以便将主分支中的每个新更改集成到我的管道中。
但是,在完成每个构建之后,我必须运行推送到我的容器注册表中的该映像的一个新实例,并将其部署为一个新的应用服务,所有这些过程都是从 Azure 门户服务手动完成的。
我一直在阅读,我需要的是使用我的 Azure 管道执行持续部署。在我azure-pipelines.acr.yml
的 CI 管道工作流中,有以下步骤:
pool:
vmImage: 'ubuntu-16.04' # other options: 'macOS-10.13', 'vs2017-win2016'
variables:
buildConfiguration: 'Release'
imageName: 'zcrm365:$(Build.BuildId)'
dockerId: 'zcrm365' # This is my registry name access key
dockerPassword: 'my password' # Password access key
# I should create an environment variables to dockerId and dockerPassword
steps:
# Build a docker image
- script: |
docker build -t $(dockerId)/$(imageName) -f ZAccountSyncService/Dockerfile . # add options to this command to meet your needs
docker build -t $(dockerId).azurecr.io/$(imageName) -f ZAccountSyncService/Dockerfile .
docker login -u $(dockerId) -p $(dockerPassword) $(dockerId).azurecr.io
docker images
docker push $(dockerId).azurecr.io/$(imageName)
##### DEPLOY A WEB APP ########
- script: dotnet publish --output $(Build.ArtifactStagingDirectory)
# Publish the output of our build to Azure Pipelines
- task: PublishBuildArtifacts@1
- task: DotNetCoreCLI@2
inputs:
command: publish
# our repository seems has no web project
publishWebProjects: False
# We should specify your .csproj in project(s) option.
projects: ""
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
zipAfterPublish: True
# CREATING AN Azure App Service Deploy task
- task: AzureRmWebAppDeployment@3
inputs:
# Is this my ID Subscription?
azureSubscription: '4e65758d-dbf5-456f-bb55-6b92273772dd'
WebAppName: 'zcrm-365'
Package: $(System.ArtifactsDirectory)/**/*.zip
而且,在我的构建管道中,我得到了这个输出错误:
Job Job: Step input azureSubscription references service connection ID SUBSCRIPTION which could not be found. The service connection does not exist or has not been authorized for use. For authorization details, refer to https://aka.ms/yamlauthz.
我正在尝试这个过程,并且我有一个激活的 Azure 订阅,但是我无法设置到它的连接。
如何设置我的服务连接以连接到 Azure 资源管理器并可以创建我的应用服务?
我们的想法是执行此步骤,以便使用我正在执行的 CI 流程来创建我的发布管道。