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

PermissionError occurs at the creating ACR task step when executing az containerapp up on Windows #5743

Closed
horihiro opened this issue Jan 10, 2023 · 6 comments · Fixed by #5749
Assignees
Labels
Auto-Assign Auto assign by bot ContainerApp CXP Attention This issue is handled by CXP team. needs-team-attention This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@horihiro
Copy link

horihiro commented Jan 10, 2023

This is autogenerated. Please review and update as needed.

Describe the bug

When executing az containerapp up without Dockerfile on Windows OS, PermissionError occurs at the ACR task creation step.
It seems that temporary files cannot be accessed.
This issue can be reproduced on Windows Sandbox also.

Command Name
az containerapp up Extension Name: containerapp. Version: 0.3.20.

Errors:
The following traceback was generated on Windows Sandbox.

The command failed with an unexpected error. Here is the traceback:
[Errno 13] Permission denied: 'C:\\Users\\WDAGUT~1\\AppData\\Local\\Temp\\tmpaa2d2k9z'
Traceback (most recent call last):
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 663, in execute
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 718, in _run_job
  File "C:\Users\WDAGUtilityAccount\.azure\cliextensions\containerapp\azext_containerapp\_client_factory.py", line 28, in _polish_bad_errors
    raise ex
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 697, in _run_job
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 333, in __call__
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
  File "C:\Users\WDAGUtilityAccount\.azure\cliextensions\containerapp\azext_containerapp\custom.py", line 2712, in containerapp_up
    app.run_acr_build(dockerfile, source, quiet=False, build_from_source=not _has_dockerfile(source, dockerfile))
  File "C:\Users\WDAGUtilityAccount\.azure\cliextensions\containerapp\azext_containerapp\_up_utils.py", line 407, in run_acr_build
    self.build_container_from_source(image_name, source)
  File "C:\Users\WDAGUtilityAccount\.azure\cliextensions\containerapp\azext_containerapp\_up_utils.py", line 375, in build_container_from_source
    acr_task_create(self.cmd, task_client, task_name, registry_name, context_path="/dev/null", file=task_file.name)
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/acr/task.py", line 137, in acr_task_create
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/acr/task.py", line 292, in create_task_step
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/acr/_utils.py", line 266, in get_yaml_template
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\WDAGUT~1\\AppData\\Local\\Temp\\tmpaa2d2k9z'

To Reproduce:

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

  • Put any pre-requisite steps here...
  • az containerapp up --name {} --source {} --ingress {}

Expected Behavior

The ACR task can be added.

Environment Summary

Windows-10-10.0.22621-SP0
Python 3.10.8
Installer: MSI

azure-cli 2.44.0

Extensions:
containerapp 0.3.20

Dependencies:
msal 1.20.0
azure-mgmt-resource 21.1.0b1

Additional Context

@ghost ghost added Auto-Assign Auto assign by bot ContainerApp CXP Attention This issue is handled by CXP team. labels Jan 10, 2023
@horihiro
Copy link
Author

In case of WSL, the same command is succeeded.

@yonzhan
Copy link
Collaborator

yonzhan commented Jan 10, 2023

route to CXP team

@navba-MSFT navba-MSFT self-assigned this Jan 11, 2023
@navba-MSFT
Copy link
Contributor

@horihiro Thanks for reaching out to us and reporting this issue. We are looking into this issue and we will provide an update.

@navba-MSFT
Copy link
Contributor

@horihiro Could you please let me know if the issue occurs if you run the AzCLI from cmd prompt using admin mode ?

As per this documentation for --source parameter:

Preview: If no Dockerfile is present, a container image is generated using Oryx. See the supported Oryx runtimes here: https://github.com/microsoft/Oryx/blob/main/doc/supportedRuntimeVersions.md.

Please check if you are on the right supported platform and runtime versions:

The full list of supported platform versions for Oryx can be found here.

@navba-MSFT navba-MSFT added question The issue doesn't require a change to the product in order to be resolved. Most issues start as that needs-author-feedback More information is needed from author to address the issue. labels Jan 11, 2023
@horihiro
Copy link
Author

horihiro commented Jan 11, 2023

Even using admin mode for cmd, this issue still occurs, and updating Azure CLI to 2.44.1 cannot resolve this.

My app I tried to deploy is very simple PHP app. There is just one file index.php.
image
And it was succeeded to deploy this app from WSL(Ubuntu 22.04) by executing the same command, as I mentioned above.

Can't you reproduce this issue by your Windows with Azure CLI @ 2.44.x and containerapp extension @ 0.3.20?

@ghost ghost added needs-team-attention This issue needs attention from Azure service team or SDK team and removed needs-author-feedback More information is needed from author to address the issue. labels Jan 11, 2023
@horihiro
Copy link
Author

horihiro commented Jan 11, 2023

Adding delete=False option to NamedTemporaryFile at this line has possibility to resolve this issue like this.
# Of cause, manual tmp file deletion is needed if delete=False option is added.

Behavior of NamedTemporaryFile depends on OS.

navba-MSFT added a commit to navba-MSFT/azure-cli-extensions that referenced this issue Jan 12, 2023
 fixes Azure#5743 PermissionError for temp file

We get the below error When executing az containerapp up without Dockerfile on Windows OS, PermissionError occurs at the ACR task creation step.
It seems that temporary files cannot be accessed. This issue can be reproduced on Windows Sandbox also. And it was succeeded to deploy this app from WSL(Ubuntu 22.04) by executing the same command.

```
  File "C:\Users\WDAGUtilityAccount\.azure\cliextensions\containerapp\azext_containerapp\_up_utils.py", line 407, in run_acr_build
    self.build_container_from_source(image_name, source)
  File "C:\Users\WDAGUtilityAccount\.azure\cliextensions\containerapp\azext_containerapp\_up_utils.py", line 375, in build_container_from_source
    acr_task_create(self.cmd, task_client, task_name, registry_name, context_path="/dev/null", file=task_file.name)
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/acr/task.py", line 137, in acr_task_create
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/acr/task.py", line 292, in create_task_step
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/acr/_utils.py", line 266, in get_yaml_template
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\WDAGUT~1\\AppData\\Local\\Temp\\tmpaa2d2k9z'
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Assign Auto assign by bot ContainerApp CXP Attention This issue is handled by CXP team. needs-team-attention This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
3 participants