Fork or clone this repository and create your own repository as follows:
cp -rf sample-project <appropriate path>
git init
git add .
git commit -m "first commit"
git branch -M main
git remote add origin <your-repository-url>
git push -u origin main
az login
SUBSCRIPTION_ID="your-subscription-id"
RESOURCE_GROUP="your-resource-group-name"
LOCATION="your-rg-location"
CONTAINERAPPS_ENVIRONMENT="your-container-app-environment-name"
CONTAINER_APP_NAME="your-container-app-namae"
CONTAINER_REGISTRY="your-container-registry-name"
REPOSITORY_NAME="your-repository-name"
SERVICE_PRINCIPAL_NAME="your-service-principal-name"
az group create \
--name $RESOURCE_GROUP \
--location $LOCATION
az acr create --resource-group $RESOURCE_GROUP --name $CONTAINER_REGISTRY --sku Basic --admin-enabled true
az acr login --name $CONTAINER_REGISTRY
docker build -t $REPOSITORY_NAME .
docker tag $REPOSITORY_NAME $CONTAINER_REGISTRY.azurecr.io/$REPOSITORY_NAME:v1
docker push $CONTAINER_REGISTRY.azurecr.io/$REPOSITORY_NAME:v1
az containerapp env create \
--name $CONTAINERAPPS_ENVIRONMENT \
--resource-group $RESOURCE_GROUP \
--location $LOCATION
az containerapp create \
--image $CONTAINER_REGISTRY.azurecr.io/$REPOSITORY_NAME:v1 \
--name $CONTAINER_APP_NAME \
--resource-group $RESOURCE_GROUP \
--environment $CONTAINERAPPS_ENVIRONMENT \
--ingress external \
--target-port 80
az ad sp create-for-rbac --name $SERVICE_PRINCIPAL_NAME \
--role contributor \
--scopes /subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP
Secret Name | Value |
---|---|
AZURE_CREDENTIALS | your service principal |
CONTAINER_REGISTRY_PASSWORD | your container registry user name |
CONTAINER_REGISTRY_USERNAME | your container registry password |
Modify following environment variables in the sample workflow to your own values
- CONTAINER_REGISTRY
- RESOURCE_GROUP_NAME
- CONTAINERAPP_NAME
git add .
git commit -m "update workflow file"
git push origin main
- Create a new branch, commit and push
- Open a Pull Request to main branch
- Confirm that the workflow has successfully run and that the revision URL for the preview is pasted in the comments of Pulll request.
- Also confirm in Azure Portal that a revision with a traffic weight of 0 has been issued.
- Close Pull request
- Confirm that the workflow has successfully run and that the pull request comments have been updated
- Confirm that the revision you created is deactivated on Azure Portal as well.
az group delete --name $RESOURCE_GROUP