azd
템플릿에 CI/CD 파이프라인 정의 파일이 포함되지 않은 경우 애플리케이션의 빌드 및 배포를 자동화하는 파일을 만들 수 있습니다. 잘 구성된 파이프라인 정의에는 일반적으로 다음 네 가지 주요 섹션이 포함됩니다.
트리거: 특정 분기에 코드 푸시, 끌어오기 요청 또는 수동 트리거와 같이 파이프라인이 실행되어야 하는 이벤트를 지정합니다. 트리거를 정의하면 개발 활동에 대한 응답으로 파이프라인이 자동으로 실행되어 연속 통합 및 배포가 가능합니다.
사용 권한: 파이프라인이 리소스와 안전하게 상호 작용하는 데 필요한 액세스를 지정합니다. 예를 들어 리포지토리 콘텐츠를 읽거나 ID 토큰을 요청할 수 있는 권한을 부여합니다. 올바른 권한은 안전하고 성공적인 배포에 필수적입니다.
운영 체제 또는 풀: 특정 가상 머신 이미지(예
ubuntu-latest
: 에이전트 풀)와 같은 파이프라인 작업에 대한 환경을 설정합니다. 올바른 환경을 선택하면 애플리케이션의 빌드 및 배포 요구 사항과 호환됩니다.단계: 코드 체크 아웃, 종속성 설치, 인프라 빌드, 프로비전 및 Azure에 배포와 같이 파이프라인이 수행하는 작업을 나열합니다. 엔드 투 엔드 배포 프로세스를 자동화하기 위해 각 단계를 명확하게 정의해야 합니다.
다음 예제에서는 GitHub Actions 및 Azure Pipelines에 대한 파이프라인 정의 파일 및 관련 구성을 만드는 방법을 보여 줍니다.
GitHub Actions에서 실행 azd
하려면 다음 설정을 구성합니다.
이 템플릿을 파이프라인 정의의 시작점으로 사용합니다.
on:
workflow_dispatch:
push:
# Run when commits are pushed to mainline branch (main or master)
# Set this to the mainline branch you are using
branches:
- main
- master
# Set this permission if you are using a Federated Credential.
permissions:
id-token: write
contents: read
jobs:
build:
runs-on: ubuntu-latest
# azd build-in variables.
# This variables are always set by `azd pipeline config`
# You can set them as global env (apply to all steps) or you can add them to individual steps' environment
env:
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
AZURE_ENV_NAME: ${{ vars.AZURE_ENV_NAME }}
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }}
## Define the additional variables or secrets that are required globally (provision and deploy)
# ADDITIONAL_VARIABLE_PLACEHOLDER: ${{ variables.ADDITIONAL_VARIABLE_PLACEHOLDER }}
# ADDITIONAL_SECRET_PLACEHOLDER: ${{ secrets.ADDITIONAL_SECRET_PLACEHOLDER }}
steps:
- name: Checkout
uses: actions/checkout@v4
# using the install-azd action
- name: Install azd
uses: Azure/setup-azd@v1.0.0
# # If you want to use azd-daily build, or install it from a PR, you can remove previous step and
# # use the next one:
# - name: Install azd - daily or from PR
# # Update this scrip based on the OS - pool of your pipeline. This example is for a linux pipeline installing daily build
# run: curl -fsSL https://aka.ms/install-azd.sh | bash -s -- --version daily
# shell: pwsh
# azd set up Federated Credential by default. You can remove this step if you are using Client Credentials
- name: Log in with Azure (Federated Credentials)
if: ${{ env.AZURE_CLIENT_ID != '' }}
run: |
azd auth login `
--client-id "$Env:AZURE_CLIENT_ID" `
--federated-credential-provider "github" `
--tenant-id "$Env:AZURE_TENANT_ID"
shell: pwsh
## If you set up your pipeline with Client Credentials, remove previous step and uncomment this one
# - name: Log in with Azure (Client Credentials)
# if: ${{ env.AZURE_CREDENTIALS != '' }}
# run: |
# $info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
# Write-Host "::add-mask::$($info.clientSecret)"
# azd auth login `
# --client-id "$($info.clientId)" `
# --client-secret "$($info.clientSecret)" `
# --tenant-id "$($info.tenantId)"
# shell: pwsh
# env:
# AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
- name: Provision Infrastructure
run: azd provision --no-prompt
env:
# # uncomment this if you are using infrastructure parameters
# AZD_INITIAL_ENVIRONMENT_CONFIG: ${{ secrets.AZD_INITIAL_ENVIRONMENT_CONFIG }}
## Define the additional variables or secrets that are required only for provision
# ADDITIONAL_VARIABLE_PLACEHOLDER: ${{ variables.ADDITIONAL_VARIABLE_PLACEHOLDER }}
# ADDITIONAL_SECRET_PLACEHOLDER: ${{ secrets.ADDITIONAL_SECRET_PLACEHOLDER }}
- name: Deploy Application
run: azd deploy --no-prompt
env:
## Define the additional variables or secrets that are required only for deploy
# ADDITIONAL_VARIABLE_PLACEHOLDER: ${{ variables.ADDITIONAL_VARIABLE_PLACEHOLDER }}
# ADDITIONAL_SECRET_PLACEHOLDER: ${{ secrets.ADDITIONAL_SECRET_PLACEHOLDER }}