Bird
Raised Fist0
Azurecloud~5 mins

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

Choose your learning style10 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.

Practice

(1/5)
1. Which deployment method in Azure allows you to push your app code directly from your source code repository?
easy
A. Manual file upload
B. ZIP deployment
C. FTP deployment
D. Git deployment

Solution

  1. Step 1: Understand Git deployment

    Git deployment connects your Azure app directly to your Git repository, pushing code changes automatically.
  2. Step 2: Compare with other methods

    ZIP deployment uploads a packaged file, manual upload and FTP are manual and not direct from repo.
  3. Final Answer:

    Git deployment -> Option D
  4. Quick Check:

    Direct repo push = Git deployment [OK]
Hint: Git deployment means pushing code from your repo directly [OK]
Common Mistakes:
  • Confusing ZIP deployment with Git deployment
  • Thinking FTP is automated from repo
  • Assuming manual upload is Git-based
2. Which of the following is the correct Azure CLI command to deploy a ZIP package to an Azure Web App named myapp in resource group mygroup?
easy
A. az webapp deploy zip --resource-group mygroup --app-name myapp --file app.zip
B. az webapp deployment source config-zip --resource-group mygroup --name myapp --src app.zip
C. az deployment zip --resource-group mygroup --webapp myapp --package app.zip
D. az webapp deployment upload-zip --resource-group mygroup --name myapp --zip-file app.zip

Solution

  1. Step 1: Identify correct Azure CLI syntax for ZIP deployment

    The official command is az webapp deployment source config-zip with parameters for resource group, app name, and source ZIP file.
  2. Step 2: Check options for syntax correctness

    az webapp deployment source config-zip --resource-group mygroup --name myapp --src app.zip matches the correct command and parameters exactly; others use incorrect commands or flags.
  3. Final Answer:

    az webapp deployment source config-zip --resource-group mygroup --name myapp --src app.zip -> Option B
  4. Quick Check:

    Correct CLI command for ZIP deploy = az webapp deployment source config-zip --resource-group mygroup --name myapp --src app.zip [OK]
Hint: Remember 'config-zip' is the key command for ZIP deploy [OK]
Common Mistakes:
  • Using wrong command verbs like 'deploy' or 'upload-zip'
  • Mixing parameter names like --app-name vs --name
  • Forgetting to specify the source ZIP file with --src
3. Given this Azure DevOps pipeline snippet for CI/CD deployment:
trigger:
  branches:
    include:
      - main

steps:
- task: AzureWebApp@1
  inputs:
    azureSubscription: 'MyAzureSub'
    appName: 'myapp'
    package: '$(System.DefaultWorkingDirectory)/drop/app.zip'

What happens when you push code to the main branch?
medium
A. The pipeline triggers and deletes the Azure Web App
B. The pipeline triggers but does not deploy anything
C. The pipeline triggers and deploys the ZIP package to the Azure Web App
D. The pipeline does not trigger on main branch pushes

Solution

  1. Step 1: Analyze the trigger section

    The pipeline triggers on pushes to the main branch as specified in the trigger include list.
  2. Step 2: Understand the deployment task

    The AzureWebApp@1 task deploys the ZIP package located at the specified path to the Azure Web App named 'myapp'.
  3. Final Answer:

    The pipeline triggers and deploys the ZIP package to the Azure Web App -> Option C
  4. Quick Check:

    Push to main triggers deploy task = The pipeline triggers and deploys the ZIP package to the Azure Web App [OK]
Hint: Trigger on main means pipeline runs and deploys ZIP package [OK]
Common Mistakes:
  • Assuming pipeline triggers on other branches
  • Thinking deployment task does nothing
  • Confusing deployment with deletion
4. You configured a CI/CD pipeline to deploy your app, but the deployment fails with an authentication error. What is the most likely cause?
medium
A. Incorrect Azure subscription service connection in the pipeline
B. ZIP package file is missing from the build artifacts
C. App name in the pipeline does not match the Azure Web App
D. Pipeline trigger is set to the wrong branch

Solution

  1. Step 1: Identify cause of authentication error

    Authentication errors usually mean the pipeline cannot access Azure resources due to wrong or missing service connection credentials.
  2. Step 2: Evaluate other options

    Missing ZIP or wrong app name cause deployment errors but not authentication errors; wrong trigger prevents pipeline start.
  3. Final Answer:

    Incorrect Azure subscription service connection in the pipeline -> Option A
  4. Quick Check:

    Auth error = service connection issue [OK]
Hint: Auth errors usually mean bad Azure service connection [OK]
Common Mistakes:
  • Blaming missing ZIP for authentication errors
  • Confusing app name mismatch with auth failure
  • Assuming trigger issues cause auth errors
5. You want to automate deployment so that when code is pushed to GitHub, it builds, tests, and deploys your app to Azure automatically. Which combination of deployment methods should you use?
hard
A. CI/CD pipeline connected to GitHub with automated build and deploy steps
B. Manual ZIP deployment after pushing code to GitHub
C. FTP deployment triggered by GitHub webhook
D. Git deployment directly from GitHub without build or test

Solution

  1. Step 1: Understand automation needs

    Automating build, test, and deploy requires a CI/CD pipeline connected to the source repository.
  2. Step 2: Compare deployment methods

    Manual ZIP and FTP are manual or partial automation; Git deployment pushes code but lacks build/test automation.
  3. Final Answer:

    CI/CD pipeline connected to GitHub with automated build and deploy steps -> Option A
  4. Quick Check:

    Full automation = CI/CD pipeline [OK]
Hint: Full automation needs CI/CD pipeline linked to GitHub [OK]
Common Mistakes:
  • Thinking Git deployment automates build and test
  • Assuming FTP can automate deployment fully
  • Using manual ZIP deploy for automation
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard