Skip to content
  • English Deutsch

benjamin-abt.com

Performance is a feature | Cloud - AI - Azure - .NET - Sustainability

  • Home
  • Blog
  • Portfolio
    • Overview
    • Workshops & Training
    • Publications
  • Contact
  • Home
  • Blog

Deploy ASP.NET Core via Zip Deployment to Azure Web App

Deploy ASP.NET Core via Zip Deployment to Azure Web App
November 28, 2023 4 min read BEN ABT
ASP.NET Core .NET Csharp

This article was written in 2023. Versions, tools and recommendations may have changed since then. Newer posts are collected under ASP.NET Core.

There are various ways to deploy an application, but Zip deployment is the variant that is recommended the most - regardless of whether you are using Azure, AWS or other cloud and hosting providers.

Even .NET recommends this variant out of the box, but unfortunately there has been no built-in CLI tooling for this for many years - and all documentation examples also primarily show file deployments - and not Zip deployments

Advantages of Zip deployment

  • Faster deployment, as only one connection to the target needs to be established
  • One large file can be transferred faster than many small files; this makes the deployment itself faster
  • Since the target unpacks the Zip itself, there is no need for write access from outside, which means that access from outside can be read-only, which increases security => Your Web App files will be read-only!
  • Zip deployment only overwrites files that have changed
  • The Zip deployment deletes files that are no longer present in the new deployment

Azure DevOps

In principle, there are several options for zipping; on Azure DevOps, however, archiving via PowerShell is the best option, as this works on all agents and all operating systems.

Unfortunately, it should be noted that the PowerShell Zip was previously not compatible with the zip standard, which only changed with version 1.2.3.0 of the Microsoft.PowerShell.Archive module. Since then, 7zip is used which you can see in the logs then.

The following steps are necessary for implementation:

  • Install the PowerShell module Microsoft.PowerShell.Archive with at least version 1.2.3.0.
  • Build the application
  • Publish the application with the target runtime (also a recommendation) in a folder
  • Create a folder in which the ZIP file is to be stored
  • Zipping the application files from the publish step
  • Deploy the zip to the WebApp

*In a real environment, there would also be a separation of build and release, so that the zip has to be treated as an artifact, which I am omitting here for demo purposes.

The YAML could therefore be simplified as follows:

YAML
 1stages:
 2  - stage: Build
 3    pool:
 4      vmImage: 'ubuntu-latest'
 5    variables:
 6      - name: DOTNET_RUNTIMES
 7        value: linux-x64
 8      - name: BUILD_SOLUTION_FILE
 9        value: MyApp.sln
10      - name: PUBLISH_PROJECT_PATH
11        value: src/MyApp/MyApp.csproj
12      - name: ARTIFACTS_DIRECTORY_APP
13        value: $(Build.ArtifactStagingDirectory)/myapp/
14      - name: ARTIFACTS_DIRECTORY_APP_ARCHIVE
15        value: $(Build.ArtifactStagingDirectory)/myapp-archive/
16      - name: APP_ARCHIVE_NAME
17        value: myapp-deployment.zip
18    jobs:
19    - job: Code
20      displayName: App Build ${{ variables.DOTNET_RUNTIMES }}
21      timeoutInMinutes: 20
22      steps:
23        - checkout: self  # self represents the repo where the initial Pipelines YAML file was found
24          clean: "true"  # whether to fetch clean each time
25          fetchDepth: "0"  # the depth of commits to ask Git to fetch
26
27        - task: UseDotNet@2
28          displayName: Install .NET SDK
29          inputs:
30            useGlobalJson: true
31            workingDirectory: $(Build.SourcesDirectory) # here is your global.json
32
33        - script: dotnet restore $(BUILD_SOLUTION_FILE) --configfile NuGet.config
34          displayName: .NET Package Restore
35
36        - script: dotnet build $(BUILD_SOLUTION_FILE) -c Release --no-restore
37          displayName: .NET Build
38
39        - script: dotnet publish $(PUBLISH_PROJECT_PATH) --no-restore -c Release -o $(ARTIFACTS_DIRECTORY_APP) --self-contained --runtime $(DOTNET_RUNTIMES)
40          displayName: .NET Publish App
41
42        ## PowerShell Setup => https://github.com/PowerShell/Microsoft.PowerShell.Archive/issues/48
43        - powershell: Install-Module Microsoft.PowerShell.Archive -MinimumVersion 1.2.3.0 -Repository PSGallery -Force
44        displayName: Install PowerShell Modules
45
46        ## Create Archive Folder
47        - task: PowerShell@2 
48          displayName: Create App Zip Folder
49          inputs:
50            targetType: 'inline'
51            script: New-Item -ItemType Directory -Force -Path $(ARTIFACTS_DIRECTORY_APP_ARCHIVE)
52
53        - task: ArchiveFiles@2
54          displayName: Create App Zip Archive
55          inputs:
56            rootFolderOrFile: $(ARTIFACTS_DIRECTORY_APP)
57            includeRootFolder: false
58            archiveType: 'zip'
59            archiveFile: $(ARTIFACTS_DIRECTORY_APP_ARCHIVE)/$(APP_ARCHIVE_NAME)
60
61        - task: AzureCLI@2
62          displayName: "Azure Web App Deploy"
63          inputs:
64            azureSubscription: # service connection name
65            scriptType: pscore
66            scriptLocation: inlineScript
67            inlineScript: |
68              az webapp deploy `
69                --resource-group your-resource-group-name `
70                --name your-webapp-name `
71                --async false --clean true --restart true --type zip `
72                --src-path $(ARTIFACTS_DIRECTORY_APP_ARCHIVE)/$(APP_ARCHIVE_NAME)

This would give us a consistent deployment for ASP.NET Core applications to Azur Web Apps.

Related articles

Problem Details in ASP.NET Core and .NET 11

Oct 5, 2026 - 12 min read

Problem Details in ASP.NET Core and .NET 11

builder.Services.AddProblemDetails() registers infrastructure. It does not create an error contract. An ASP.NET Core request can fail during …

Resilience in .NET with Microsoft.Extensions.Resilience

Sep 21, 2026 - 11 min read

Resilience in .NET with Microsoft.Extensions.Resilience

Retries are the most visible resilience strategy and the easiest one to misuse. Repeating a failing call can recover from a short network …

What Matters in ASP.NET Core 11

Sep 14, 2026 - 10 min read

What Matters in ASP.NET Core 11

ASP.NET Core 11 has no single feature that fundamentally changes how web applications are built. That is not a criticism. Mature frameworks …


BEN ABT

BEN ABT

Ben is Chief Engineering Officer and Principal Software Engineer at Medialesson.de, with a strong focus on .NET and Microsoft Azure. In his professional role, he designs and builds highly scalable platforms for hybrid and cloud-based scenarios. He also advises companies and C-levels on migrating to the sovereign cloud.

He runs myCSharp.de, the largest and most active German-speaking C# community forum, actively contributes to both his own and external open-source projects and regularly shares his knowledge through his blog, at community events, conferences and as a writer for technical magazines.

Let's Work Together

Looking for an experienced Platform Architect or Engineer for your next project? Whether it's cloud migration, platform modernization or building new solutions from scratch - I'm here to help you succeed.

New Platforms

Modernization

Training & Consulting

Contact Me
X Facebook LinkedIn WhatsApp
Back Next Blog Post

Open for work!

Contact Me
BEN ABT BEN ABT Software Engineer · Microsoft MVP Passionate about .NET, Azure, performance optimization and sustainable software engineering.

Medialesson GmbH Logo

Microsoft MVP Logo

Recent posts

View all
Stop Using nginx as Your Default Static File Server in Docker

Stop Using nginx as Your Default Static File Server in …

Oct 24, 2026
Containerizing .NET in 2026 Without a Dockerfile

Containerizing .NET in 2026 Without a Dockerfile

Oct 20, 2026
Problem Details in ASP.NET Core and .NET 11

Problem Details in ASP.NET Core and .NET 11

Oct 5, 2026
Resilience in .NET with Microsoft.Extensions.Resilience

Resilience in .NET with Microsoft.Extensions.Resilience

Sep 21, 2026
What Matters in ASP.NET Core 11

What Matters in ASP.NET Core 11

Sep 14, 2026

Tags

.NET (192) Csharp (96) ASP.NET Core (48) Azure (41) DevOps (17) Docker (14) Microsoft (14) EF Core (11) Microsoft MVP (11) AI (10) GitHub (10) GitHub Copilot (10) ASP.NET (9) Security (9) Synology (9) Architecture (8) Raspberry (8) Azure Functions (7) Cloudflare (7) Bicep (6)
benjamin-abt.com

About BEN

Benjamin Abt is a Software Engineer, Platform Architect and Microsoft MVP specializing in .NET, Azure, cloud architecture, performance optimization and sustainable software development.

Connect

  • Follow me on GitHub
  • Follow me on LinkedIn
  • Follow me on Mastodon
  • Microsoft MVP profile
  • Follow SchwabenCode on GitHub
  • Follow me on X

Quick Links

  • Portfolio
  • Blog
  • Workshops & Training
  • Publications
  • Get in Touch
  • Sitemap
Open for Work

© Copyright Benjamin Abt & SchwabenCode | 2011 - 2026

Content licensed under CC BY 4.0 unless otherwise noted.

  • Impressum
  • Privacy
  • Contact