azure-cli: Unable to zip deploy a function app in the Azure Cloud Shell (version 2.29.0)

Deploying a zip file to both existing functionapp and new functionapp is not working and throws an unexpected error. Command format is az functionapp deployment source config-zip -g $ResourceGroup -n $appname --src $filename This format is as documented at ms documentation

Note this process has worked previously. All variables were checked for valid values, process appears to start and then error is thrown.

Command Name az functionapp deployment source config-zip

Errors:

The command failed with an unexpected error. Here is the traceback:
'str' object has no attribute 'value'
Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 231, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 657, in execute
    raise ex
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 720, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 691, in _run_job
    result = cmd_copy(params)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 328, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/appservice/custom.py", line 405, in enable_zip_deploy_functionapp
    return enable_zip_deploy(cmd, resource_group_name, name, src, timeout, slot)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/appservice/custom.py", line 417, in enable_zip_deploy
    scm_url = _get_scm_url(cmd, resource_group_name, name, slot)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/appservice/custom.py", line 1948, in _get_scm_url
    webapp = show_webapp(cmd, resource_group_name, name, slot=slot)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/appservice/custom.py", line 607, in show_webapp
    return _show_app(cmd, resource_group_name, name, "webapp", slot)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/appservice/custom.py", line 736, in _show_app
    "Unable to find {} '{}', in RG '{}'".format(cmd_app_type.value, name, resource_group_name),
AttributeError: 'str' object has no attribute 'value'

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

Process to replicate:

  1. Develop Azure function in Visual Studio
  2. Publish to Local Folder
  3. Zipped folder
  4. Open Cloudshell in Azure Portal (Powershell)
  5. Uploaded zip file
  6. set variables in shell
  7. executed command.
  • az functionapp deployment source config-zip -g {} -n {} --src {}

Expected Behavior

Zip file would be deployed to the Azure Function

Environment Summary

Linux-5.4.0-1061-azure-x86_64-with-debian-10.2 (Cloud Shell), Common Base Linux Delridge (quinault)
Python 3.6.10
Installer: DEB

azure-cli 2.29.0

Extensions:
application-insights 0.1.13
ai-examples 0.2.5
ssh 0.1.6

Additional Context

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 5
  • Comments: 18 (1 by maintainers)

Most upvoted comments

Work around for Ubuntu 20.04

      - script: |
          sudo apt-get remove azure-cli
          curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null
          echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/azure-cli.list
          sudo apt-get update
          sudo apt-get install azure-cli=2.28.0-1~$(lsb_release -cs)
          az version

thanks @al-cheb

For Azure DevOps on an Ubuntu20.04 agent this worked in my case (it updated the cli to 2.29.1): https://docs.microsoft.com/en-us/azure/devops/cli/azure-devops-cli-in-yaml?view=azure-devops#hosted-agent-azure-cli-version

# Update to latest Azure CLI version
- bash: pip install --pre azure-cli --extra-index-url https://azurecliprod.blob.core.windows.net/edge
  displayName: 'Upgrade Azure CLI'

We have been able to work around this issue by substituting the current az functionapp deployment source config-zip -g $ResourceGroup -n $appname --src $filename with… Publish-AzWebapp -ResourceGroupName $ResourceGroup -Name $appname -ArchivePath $filename

NOTE: We are unsure if this deploys the package differently at this time, however it allows us to at least deploy with minimal changes to our existing scripts.