0

We have a custom docker image based on Python and docker file using port 5000 to expose within the container. Also we have created a private Azure Webapp service based on Linux container in our Spoke with production and staging slot on it.

We are looking for a way to directly deploy this custom created docker image from the server to Azure Web app (Linux container) slot, so that after each docker image version creation, we can deploy the image to this Webapp slot directly and the application can be accesses over https endpoint url.

We were referring the MS document to identify the web app deployment command and passing the docker image tag, but couldn't find any az command to achieve this task to deploy the docker image built to the appservice slot

4
  • 1
    Please share more details about the issue you are facing? Commented Oct 29, 2024 at 15:11
  • Question modified. basically looking for some kind of automation or az cli command to deploy the custom docker image to webapp slot directly. Commented Oct 29, 2024 at 15:36
  • Use az webapp config container set --docker-custom-image-name MyDockerCustomImage --docker-registry-server-password StrongPassword --docker-registry-server-url https://{azure-container-registry-name}.azurecr.io --docker-registry-server-user DockerUserId --name MyWebApp --resource-group MyResourceGroup (or) az webapp config container set --docker-custom-image-name MyDockerCustomImage --docker-registry-server-url https://{azure-container-registry-name}.azurecr.io --name MyWebApp --resource-group MyResourceGroup Commented Oct 30, 2024 at 8:48
  • Other way az webapp create --resource-group MyResourceGroup --plan MyAppServicePlan --name MyWebApp --deployment-container-image-name MyACR.azurecr.io/myimage:latest Commented Oct 30, 2024 at 8:51

1 Answer 1

0

Are you having problem with Container Apps or App Services?

To deploy to Azure Container Apps, I use these scripts:

# Step 6: Create a Container Apps environment
Write-Host "`nCreating a Container Apps environment named '${environmentName}'"
$containerEnv = az containerapp env create `
                         --name $environmentName  `
                         --resource-group $rgname `
                         --location $location `
                         --logs-workspace-id $workspaceId `
                         --logs-workspace-key $workspaceKey `
                         --output json | ConvertFrom-Json
Write-Host "Container Apps Environment created"

# Step 7: Create Azure Container App for CloudDebugger
# Set DEPLOY_TRIGGER to a random value to force a redeployment
Write-Host "`nCreating Azure Container App for CloudDebugger"
$randomValue = [guid]::NewGuid().ToString()
$container = az containerapp create `
    --name $containerAppName `
    --environment $environmentName `
    --resource-group $rgname `
    --user-assigned $identityId `
    --registry-identity $identityId `
    --registry-server "${acrname}.azurecr.io" `
    --image "${acrname}.azurecr.io/${imagename}:latest" `
    --target-port 8080 `
    --ingress external `
    --cpu 0.25 `
    --memory 0.5 `
    --min-replicas 1 `
    --max-replicas 1 `
    --env-vars AZURE_CLIENT_ID=$clientId DEPLOY_TRIGGER=$randomValue `
    --output json | ConvertFrom-Json
$containerId = $container.id 

if you have problems with deploying to App Services, then I have a blog post about that here: Deploy Container to Azure App Services with System-Assigned Identity

Where I use this command to update the container deployment:

$imagePath = "${acrname}.azurecr.io/${imagename}:latest"
Write-Host "`n`nChange the service to use the container ${imagePath}."
az webapp config container set `
  --name $AppServiceName_container_linux `
  --resource-group $rgname `
  --container-image-name $imagePath `
  --output json | ConvertFrom-Json
Sign up to request clarification or add additional context in comments.

2 Comments

We haven't configured the Appservice with ACR integration as of now. But what we are trying to achieve is directly deploy the docker image from the build server using az webapp command or any other way, where we can pass the acr endpoint and image tag. Also we are performing this in Linux build server and looking for az bash based commands or scripts
See my blog post, it contains scripts to do all the steps using the az commands. let me know if you have any specific question

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.