Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

az webapp up - AttributeError: 'ZipFile' object has no attribute 'mkdir' #27155

Open
jonasheschl opened this issue Aug 11, 2023 · 6 comments
Open
Assignees
Labels
app-service-general Auto-Assign Auto assign by bot Auto-Resolve Auto resolve by bot bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention This issue needs attention from Azure service team or SDK team Possible-Solution Service Attention This issue is responsible by Azure service team. Similar-Issue Web Apps az webapp

Comments

@jonasheschl
Copy link

Describe the bug

When attempting to deploy an ASP.NET Core Web API to Azure App Service, the error AttributeError: 'ZipFile' object has no attribute 'mkdir' is returned. This error occurs when I run az webapp up --name REDACTED --sku F1 --resource-group REDACTED --location germanywestcentral --os-type Linux in the directory of the Web API server.

The ASP.NET Core Web API project is structured like this:

/api-server
  /ApiServerProject <- Deployment command run here
  /ApiServerLib
  api-server.sln
  [...]

Related command

az webapp up

Errors

The command failed with an unexpected error. Here is the traceback:
'ZipFile' object has no attribute 'mkdir'
Traceback (most recent call last):
  File "/opt/az/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
    raise ex
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 718, in _run_job
    return cmd_copy.exception_handler(ex)
  File "/opt/az/lib/python3.10/site-packages/azure/cli/command_modules/appservice/commands.py", line 46, in _ex_handler
    raise ex
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
    result = cmd_copy(params)
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/opt/az/lib/python3.10/site-packages/azure/cli/command_modules/appservice/custom.py", line 4773, in webapp_up
    zip_file_path = zip_contents_from_dir(src_dir, language)
  File "/opt/az/lib/python3.10/site-packages/azure/cli/command_modules/appservice/_create_util.py", line 71, in zip_contents_from_dir
    zip_dotnet_project_references(abs_src, "{}".format(zip_file_path))
  File "/opt/az/lib/python3.10/site-packages/azure/cli/command_modules/appservice/_create_util.py", line 574, in zip_dotnet_project_references
    tmp_zf.mkdir(DOTNET_REFERENCES_DIR_IN_ZIP)
AttributeError: 'ZipFile' object has no attribute 'mkdir'

Issue script & Debug output

The generated logs are unfortunately too extensive to reliably check for sensitive information.

Expected behavior

The Web API solution is deployed to azure App Service.

Environment Summary

az --version

azure-cli                         2.51.0

core                              2.51.0
telemetry                          1.1.0

Dependencies:
msal                            1.24.0b1
azure-mgmt-resource             23.1.0b2

Python location '/opt/az/bin/python3'
Extensions directory '/home/jonas/.azure/cliextensions'

Python (Linux) 3.10.10 (main, Jul 27 2023, 07:10:25) [GCC 11.3.0]

Legal docs and information: aka.ms/AzureCliLegal


Your CLI is up-to-date.

uname -a

Linux pop-os 6.4.6-76060406-generic #202307241739~1690928105~22.04~d567a38 SMP PREEMPT_DYNAMIC Tue A x86_64 x86_64 x86_64 GNU/Linux

Additional context

No response

@jonasheschl jonasheschl added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Aug 11, 2023
@yonzhan
Copy link
Collaborator

yonzhan commented Aug 11, 2023

Thank you for opening this issue, we will look into it.

@azure-client-tools-bot-prd
Copy link

Hi @jonasheschl
Find similar issue #26413.

Issue title az webapp up AttributeError: 'ZipFile' object has no attribute 'mkdir'
Create time 2023-05-11
Comment number 14

Possible solution:
As mentioned in the previous issue, the error occurs due to the lack of the mkdir method in Python 3.10, which is the version bundled with azure-cli. One solution is to upgrade to Python 3.11, which has the mkdir method. Another solution is to wait for azure-cli to bundle Python 3.11.


Please confirm if this resolves your issue.

@microsoft-github-policy-service microsoft-github-policy-service bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. Web Apps az webapp CXP Attention This issue is handled by CXP team. Auto-Assign Auto assign by bot app-service-general labels Aug 11, 2023
@jonasheschl
Copy link
Author

Hi @jonasheschl Find similar issue #26413.

Issue title az webapp up AttributeError: 'ZipFile' object has no attribute 'mkdir'
Create time 2023-05-11
Comment number 14

Possible solution: As mentioned in the previous issue, the error occurs due to the lack of the mkdir method in Python 3.10, which is the version bundled with azure-cli. One solution is to upgrade to Python 3.11, which has the mkdir method. Another solution is to wait for azure-cli to bundle Python 3.11.

Please confirm if this resolves your issue.

As far as I can tell, azure-cli is not designed to have its bundled Python interpreter manually swapped out. I also can't find documentation on how swapping the interpreter would work. See #24494.

@navba-MSFT navba-MSFT added Service Attention This issue is responsible by Azure service team. needs-team-attention This issue needs attention from Azure service team or SDK team and removed CXP Attention This issue is handled by CXP team. labels Aug 14, 2023
@navba-MSFT
Copy link
Contributor

Adding service team to look into this.

@jonasheschl
Copy link
Author

As a temporary workaround, I was able to deploy the project to Azure App Service using the Azure Rider extension.

@jonasheschl
Copy link
Author

Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app-service-general Auto-Assign Auto assign by bot Auto-Resolve Auto resolve by bot bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention This issue needs attention from Azure service team or SDK team Possible-Solution Service Attention This issue is responsible by Azure service team. Similar-Issue Web Apps az webapp
Projects
None yet
Development

No branches or pull requests

4 participants