asp-net コア プロジェクトをビルドし、そこから Docker イメージをビルドして Azure Container Registry にプッシュする Azure パイプラインがあります。
このパイプラインはazure-pipelines.acr.yml
ファイルから作成されます。Deployments ブランチに対して実行する各 git push 操作は、新しいビルドでパイプラインに変換されます。
ここまでは、マスター ブランチの新しい変更をパイプラインに統合するために、CI パイプラインを用意しました。
しかし、ビルドを完了するたびに、コンテナー レジストリにプッシュされたそのイメージの新しいインスタンスを実行し、それを新しい App Service としてデプロイする必要があります。このすべてのプロセスは、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 Resource Manager に接続し、アプリ サービスを作成するためにサービス接続をセットアップするにはどうすればよいですか?
アイデアは、実行中の CI プロセスを使用してリリース パイプラインの作成に進むために、このステップを実行することです。