Notitie
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen u aan te melden of de directory te wijzigen.
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen de mappen te wijzigen.
Als uw azd sjabloon geen CI/CD-pijplijndefinitiebestand bevat, kunt u er een maken om de build en implementatie van uw toepassing te automatiseren. Een goed gestructureerde pijplijndefinitie bevat doorgaans vier hoofdsecties:
Trigger: Hiermee geeft u gebeurtenissen op wanneer de pijplijn moet worden uitgevoerd, zoals codepushen naar specifieke vertakkingen, pull-aanvragen of handmatige triggers. Het definiëren van triggers zorgt ervoor dat uw pijplijn automatisch wordt uitgevoerd als reactie op ontwikkelingsactiviteiten, waardoor continue integratie en implementatie mogelijk is.
Machtigingen: hiermee geeft u de toegang op die vereist is voor de pijplijn om veilig met resources te communiceren. U kunt bijvoorbeeld machtigingen verlenen om de inhoud van de opslagplaats te lezen of identiteitstokens aan te vragen. Juiste machtigingen zijn essentieel voor veilige en succesvolle implementaties.
Besturingssysteem of pool: hiermee stelt u de omgeving in voor pipeline taken, zoals een specifieke virtuele machïne afbeelding (bijvoorbeeld
ubuntu-latest) of een agentpool. Het kiezen van de juiste omgeving zorgt voor compatibiliteit met de build- en implementatievereisten van uw toepassing.Stappen: Geeft een overzicht van de taken die de pijplijn uitvoert, zoals het uitchecken van code, het installeren van afhankelijkheden, het bouwen, inrichten van infrastructuur en het implementeren in Azure. Elke stap moet duidelijk worden gedefinieerd om het end-to-end implementatieproces te automatiseren.
In de volgende voorbeelden ziet u hoe u een pijplijndefinitiebestand en gerelateerde configuraties maakt voor GitHub Actions en Azure Pipelines.
Configureer de volgende instellingen om uit te voeren azd in GitHub Actions:
- Verleen toegang tot
id-token: writeencontents: readscopes. -
Installeer de azd-actie, tenzij je een Docker-afbeelding met
azdvooraf geïnstalleerd gebruikt.
Gebruik deze sjabloon als uitgangspunt voor uw pijplijndefinitie:
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 }}