0
0
Azurecloud~5 mins

Deployment methods (Git, ZIP, CI/CD) in Azure - Commands & Configuration

Choose your learning style9 modes available
Introduction
Deploying your app to Azure means moving your code so it can run on the cloud. You can do this by sending your code directly with Git, uploading a ZIP file, or using automated pipelines called CI/CD. Each method helps you update your app in different ways.
When you want to quickly update your app by pushing code changes with Git.
When you have a packaged app in a ZIP file ready to upload for deployment.
When you want to automate testing and deployment every time you change your code using CI/CD pipelines.
When you want to keep your deployment process consistent and repeatable without manual steps.
When you want to deploy from your local machine or from a remote repository.
Commands
This command sets up a Git repository on Azure for your web app so you can push your code directly from your local machine.
Terminal
az webapp deployment source config-local-git --name example-app --resource-group example-rg
Expected OutputExpected
Git remote url: https://example-app.scm.azurewebsites.net/example-app.git
--name - Specifies the name of your Azure web app
--resource-group - Specifies the resource group where your app is located
Adds the Azure Git remote to your local Git repository so you can push your code to Azure.
Terminal
git remote add azure https://example-app.scm.azurewebsites.net/example-app.git
Expected OutputExpected
No output (command runs silently)
Pushes your local main branch code to Azure, triggering deployment of your app.
Terminal
git push azure main
Expected OutputExpected
Enumerating objects: 10, done. Counting objects: 100% (10/10), done. Delta compression using up to 4 threads Compressing objects: 100% (8/8), done. Writing objects: 100% (10/10), 1.2 KiB | 1.2 MiB/s, done. Total 10 (delta 2), reused 0 (delta 0) remote: Updating branch 'main'. remote: Syncing repository... remote: Deployment successful. To https://example-app.scm.azurewebsites.net/example-app.git abc1234..def5678 main -> main
Uploads and deploys your app packaged as a ZIP file to Azure web app.
Terminal
az webapp deployment source config-zip --resource-group example-rg --name example-app --src ./app.zip
Expected OutputExpected
Deployment successful.
--src - Path to the ZIP file containing your app code
Creates a CI/CD pipeline in Azure DevOps that automatically builds and deploys your app when you push code to the main branch.
Terminal
az pipelines create --name example-pipeline --repository https://github.com/example/repo --branch main --yml-path azure-pipelines.yml
Expected OutputExpected
Pipeline 'example-pipeline' created successfully.
--repository - URL of the Git repository to connect
--branch - Branch to trigger the pipeline
--yml-path - Path to the pipeline YAML configuration file
Key Concept

If you remember nothing else from this pattern, remember: Azure lets you deploy your app by pushing code with Git, uploading ZIP files, or automating with CI/CD pipelines to keep your app updated easily.

Common Mistakes
Trying to push code to Azure Git without setting up the local Git remote first.
The push will fail because Azure does not know where to receive your code.
Run the command to configure local Git deployment and add the Azure remote before pushing.
Uploading a ZIP file that does not contain the app files at the root level.
Azure won't find your app files and deployment will fail or the app won't run.
Make sure your ZIP file contains your app files directly at the root, not inside nested folders.
Not configuring the CI/CD pipeline YAML file correctly before creating the pipeline.
The pipeline will fail to build or deploy your app automatically.
Test your pipeline YAML locally or in a test environment to ensure it works before linking it to your repo.
Summary
Use 'az webapp deployment source config-local-git' to set up Git deployment and push code directly.
Use 'az webapp deployment source config-zip' to deploy your app by uploading a ZIP file.
Use Azure DevOps pipelines with a YAML file to automate build and deployment with CI/CD.