Skip to content

Instantly share code, notes, and snippets.

@Debjyoti30
Created January 14, 2025 08:28
Show Gist options
  • Select an option

  • Save Debjyoti30/518fe40eb892d020badb29ca884836a2 to your computer and use it in GitHub Desktop.

Select an option

Save Debjyoti30/518fe40eb892d020badb29ca884836a2 to your computer and use it in GitHub Desktop.
Build image from the Docker file and provision Azure container app Job using the Image
# cd-pipeline.yml
trigger:
- main
pool:
vmImage: 'ubuntu-latest'
variables:
artifactName: 'LibraryContainerAppJob'
containerRegistry: '<Your_ACR_Name>'
imageName: 'librarycontainerappjob'
location: '<Your_Location>'
containerAppName: 'LibraryContainerAppJob'
envName: '<Your_Container_App_Env_Name>'
resourceGroupName: '<Your_Resource_Group_Name>'
subscriptionId: '<Your_Subscription_Id>'
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download Dockerfile Package from Azure Artifacts'
inputs:
artifactName: '$(artifactName)'
targetPath: '$(Pipeline.Workspace)'
- task: Bash@3
displayName: 'Build and Push Docker Image to ACR using az acr build'
inputs:
targetType: 'inline'
script: |
echo "Building and pushing Docker image using az acr build..."
az acr build --registry $(containerRegistry) --image $(imageName):$(Build.BuildId) $(Pipeline.Workspace)/$(artifactName)
- task: Bash@3
displayName: 'Create Azure Container App Job'
inputs:
targetType: 'inline'
script: |
echo "Creating Azure Container App Job..."
az containerapp job create --name $(containerAppName) --resource-group $(resourceGroupName) --environment $(envName) --image $(containerRegistry).azurecr.io/$(imageName):$(Build.BuildId) --cpu 0.5 --memory 1.0Gi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment