0

I am running this task in azure pipeline with microsoft hosted windows-latest agent but this step shows OSError: [Errno 22] Invalid argument: 'D:\a\1\a\**\*.zip' error.

- task: AzureCLI@2
  displayName: Azure CLI
  inputs:
    azureSubscription: '$(Parameters.connectedServiceName)'
    scriptType: ps
    scriptLocation: inlineScript
    inlineScript: |

      $apps= @('JustGoTestAgain, justgotesttwo')

      foreach ($app in $apps) {
         az webapp deployment source config-zip -g test_group -n $app --src '$(build.artifactstagingdirectory)/**/*.zip'
      }
WARNING: Getting scm site credentials for zip deployment
ERROR: The command failed with an unexpected error. Here is the traceback:
ERROR: [Errno 22] Invalid argument: 'D:\\a\\1\\a\\**\\*.zip'
Traceback (most recent call last):
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 231, in invoke
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 657, in execute
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 720, in _run_jobs_serially
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 691, in _run_job
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 328, in __call__
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/appservice/custom.py", line 402, in enable_zip_deploy_webapp
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/appservice/custom.py", line 428, in enable_zip_deploy
OSError: [Errno 22] Invalid argument: 'D:\\a\\1\\a\\**\\*.zip'
To open an issue, please run: 'az feedback'
##[error]Script failed with exit code: 1

How to solve this issue?

Akash paul
  • 93
  • 2
  • 9

1 Answers1

0

First, you need to enable zip deployment for a webapp

The WEBSITE_RUN_FROM_PACKAGE app setting enables running from a package. To set it, run the following command with Azure CLI:

az webapp config appsettings set --resource-group <group-name> --name <app-name> --settings WEBSITE_RUN_FROM_PACKAGE="1"

WEBSITE_RUN_FROM_PACKAGE="1" lets you run your app from a package local to your app. You can also run from a remote package

Run the package

The easiest way to run a package in your App Service is with the Azure CLI az webapp deployment source config-zip command.

Azure CLI

az webapp deployment source config-zip --resource-group <group-name> --name <app-name> --src <filename>.zip

Because the WEBSITE_RUN_FROM_PACKAGE app setting is set, this command doesn't extract the package content to the D:\home\site\wwwroot directory of your app. Instead, it uploads the ZIP file as-is to D:\home\data\SitePackages, and creates a packagename.txt in the same directory, that contains the name of the ZIP package to load at runtime.

If you upload your ZIP package in a different way (such as FTP), you need to create the packagename.txt file manually under D:\home\data\SitePackages directory.

The command also restarts the app. Because WEBSITE_RUN_FROM_PACKAGE is set, App Service mounts the uploaded package as the read-only wwwroot directory and runs the app directly from that mounted directory.

You can refer to Run your app in Azure App Service directly from a ZIP package and Azure DevOps Doesn't Publish Web App from ZIP Deploy, Runs It as Read-Only ZIP Package Instead

Ecstasy
  • 1,866
  • 1
  • 9
  • 17