Share via

.NET Azure deploy problem

GringoUA 0 Reputation points
2024-08-24T13:16:45.9+00:00

I have problem with the deployment of a .Net app via gitlab pipline. The problem appears when azure CLI unzips provided archive. It creates an additional folder in wwwroot instead of placing all files directly in wwwroot.

Here is my code:

- az webapp deploy --resource-group <groupName> --name <appName> --src-path publish.zip --type zip
Azure Functions
Azure Functions

An Azure service that provides an event-driven serverless compute platform.

Developer technologies | .NET | Other
0 comments No comments

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 41,386 Reputation points MVP Volunteer Moderator
    2026-04-25T18:26:51.7333333+00:00

    Hello !

    Thank you for posting on MS Learn Q&A.

    The issue is almost certainly the structure of publish.zip not the az webapp deploy command.

    Azure/Kudu extracts the ZIP exactly as packaged into wwwroot, it does not flatten the folder structure.

    ZIP deploy unpacks the package contents into D:\home\site\wwwroot or /home/site/wwwroot for App Service and for Azure Functions the ZIP must have host.json at the root after extraction. If the parent folder is included, Azure will not find the expected files in wwwroot.

    https://learn.microsoft.com/en-us/azure/app-service/deploy-zip

    So this is wrong:

    zip -r publish.zip publish
    

    That creates:

    publish/
      host.json
      MyFunctionApp.dll
      ...
    

    Azure extracts it as:

    wwwroot/publish/...
    

    Instead, zip the contents of the publish folder:

    script:
      - dotnet publish -c Release -o publish
      - cd publish
      - zip -r ../publish.zip .
      - cd ..
      - az webapp deploy --resource-group <groupName> --name <appName> --src-path publish.zip --type zip
    

    For Windows PS :

    dotnet publish -c Release -o publish
    Compress-Archive -Path .\publish\* -DestinationPath .\publish.zip -Force
    az webapp deploy --resource-group <groupName> --name <appName> --src-path .\publish.zip --type zip
    

    You can verify before deploying:

    unzip -l publish.zip | head
    

    You should see files directly at the root, for example:

    host.json
    MyApp.dll
    web.config
    

    Not:

    publish/host.json
    publish/MyApp.dll
    

    If this is an Azure Function App, I would also prefer the Functions specific command:

    az functionapp deployment source config-zip \
      --resource-group <groupName> \
      --name <appName> \
      --src publish.zip
    
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.