sparse-intern-71089
02/09/2024, 3:33 PMadventurous-butcher-54166
02/13/2024, 4:40 PMadmin_user_enabled=False
◦ Enable managed identity on the App Service: identity=web.ManagedServiceIdentityArgs(type=web.ManagedServiceIdentityType.SYSTEM_ASSIGNED),
◦ Assign the AcrPull role on the App Service. See this gist for how to do that in Pulumi/Python.
◦ Remove the docker login related ENV vars
◦ Set this option in site_config: acr_use_managed_identity_creds=True
• Use OIDC credentials in your workflow instead of client credentials. I used this bash script in the past before migrating the provisioning of this Pulumi (can't share that right now). It will automatically create the service principal and store the credential as an environment secret in your GitHub repo if gh
cli is present. Otherwise see GitHub and Azure docs.
• Don't use latest
tags for containers as it's an anti-pattern and can cause various problems and confusion
◦ Instead use the docker-metadata-action to automatically tag your images with branch name, github sha. Pull request builds will get a pr-number tag. Can even support semver tags if you implement that.
◦ This makes it much clearer what version of your container is actually deployed
• For App Service production workloads which need zero-downtime:
◦ Go with the Premium tier app services
◦ Create deployment slots
◦ Have your CI/CD workflow deploy release candidates to a staging slot and then swap that into production
◦ I've used az cli in a workflow for doing that like so:
◦ az webapp deployment slot swap -s slot_name -n app_name -g resource_group
gray-fall-86820
02/13/2024, 4:52 PMname: Build and deploy - Test
on:
push:
paths-ignore:
- '**/README.md'
- '**/.github/workflows/**.yml'
branches:
- develop
workflow_dispatch:
jobs:
lint:
runs-on: ubuntu-latest
environment: Testing
steps:
- uses: actions/checkout@v2
- uses: psf/black@stable
deploy:
runs-on: ubuntu-latest
environment: Testing
steps:
- uses: actions/checkout@v2
- uses: azure/docker-login@v1
with:
login-server: ${{ secrets.ACR_DEV_SERVER }}
username: ${{ secrets.ACR_DEV_USERNAME }}
password: ${{ secrets.ACR_DEV_PASSWORD }}
- run: |
docker build -t ${{ secrets.ACR_DEV_SERVER }}/repo-name:${{ github.sha }} .
docker push ${{ secrets.ACR_DEV_SERVER }}/repo-name:${{ github.sha }}
- uses: azure/webapps-deploy@v2
with:
app-name: 'App Name'
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
images: '${{ secrets.ACR_DEV_SERVER}}/repo-name:${{ github.sha }}'
gray-fall-86820
02/13/2024, 5:42 PMadventurous-butcher-54166
02/13/2024, 6:00 PMwork-dir
to where your Pulumi code lives
• command: up | preview
If you export outputs from the stack these can then be referenced in consecutive workflow steps - assuming your pulumi step has the id: pulumi
and you have a stack output named registry_endpoint
${{ steps.pulumi.outputs.registry_endpoint }}"
And if you install the Pulumi GitHub App you will get automatic comments on your pull requests with the results of a pulumi action.gray-fall-86820
02/13/2024, 8:56 PM