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 storage account create succeed but returns an invalid json #10687

Closed
tamirkamara opened this issue Sep 29, 2019 · 12 comments
Closed

az storage account create succeed but returns an invalid json #10687

tamirkamara opened this issue Sep 29, 2019 · 12 comments
Assignees
Labels
Core CLI core infrastructure Storage az storage
Milestone

Comments

@tamirkamara
Copy link

Describe the bug
A recent change in the storage account create command introduced a fixed warning about the default kind moving to StorageV2 in the near future. It is printed even when the output is requested in json which makes downstream apps or extensions (like image copy) fail in parsing.
Since the message is fixed without any conditions there's no way to avoid the problem.
I don't expect warnings to be printed when output is set to json, or, at the very least, this specific warning to only be printed when the user doesn't specify the kind and relies on the default.

To Reproduce
run this command:
az storage account create --name uksouth0fpcpuevwgzndpb4c --resource-group image-copy-rg --location uksouth --sku Standard_LRS --output json

Expected behavior
A valid json is printed on the screen

Environment summary
Windows-10-10.0.18362-SP0
Python 3.6.6
Shell: cmd.exe

azure-cli 2.0.74

Extensions:
imagecopyextension 0.2.1

Additional Context

At current state, this break the image-copy extension in all scenarios and impacts several customers already.

@tamirkamara tamirkamara changed the title az storage create succeed but returns an invalid json az storage account create succeed but returns an invalid json Sep 29, 2019
@jiasli jiasli added Core CLI core infrastructure Storage az storage labels Sep 30, 2019
@jiasli jiasli self-assigned this Sep 30, 2019
@jiasli
Copy link
Member

jiasli commented Sep 30, 2019

All logger messages are written to std.err which will not be saved to files or variables.

To save to a variable (on Linux), out=$(az storage account create --name {} --resource-group {} --location eastus2 --sku Standard_LRS --output json)

To save to a file, az storage account create --name {} --resource-group {} --location eastus2 --sku Standard_LRS --output json > output.json

To disable the warning, append 2>NUL in cmd, 2>$null in PowerShell or 2>/dev/null on Linux (2 stands for std.err).

If there is still problem, please kindly share the full script. Thanks.

@tamirkamara
Copy link
Author

Hi,
Thank you @jiasli however I don't think your suggestion is practical in my scenario - I'm working from within python as a cli extension and calling other cli commands. This was the decision back when the extension was created...
You can view the section where this happens here: https://github.com/Azure/azure-cli-extensions/blob/master/src/image-copy/azext_imagecopy/cli_utils.py#L21

@tjprescott was in the loop then.

@yonzhan
Copy link
Collaborator

yonzhan commented Oct 19, 2019

@jiasli put to next Sprint.

@Aanerud
Copy link

Aanerud commented Nov 5, 2019

+1 This is urgent, as Azure is getting now two new local sites, and I can't migrate to the local sites, a s this does not work.

@jiasli
Copy link
Member

jiasli commented Nov 19, 2019

Is it possible not to capture standard error?
https://docs.python.org/3.8/library/subprocess.html#subprocess.check_output

This has actually been discussed before in #9891 (comment).

@yonzhan yonzhan modified the milestones: S161, S162 Dec 1, 2019
@yonzhan
Copy link
Collaborator

yonzhan commented Dec 15, 2019

@Aanerud any update for this issue?

@yonzhan yonzhan modified the milestones: S162, S163 Dec 15, 2019
@yonzhan
Copy link
Collaborator

yonzhan commented Dec 30, 2019

@Aanerud any update ?

@yonzhan yonzhan modified the milestones: S163, S164 Dec 30, 2019
@Aanerud
Copy link

Aanerud commented Dec 30, 2019

I used the workaround described in the a similar ticket. I have not updated Azure CLI after, as the workaround works.

@yonzhan
Copy link
Collaborator

yonzhan commented Dec 30, 2019

@Aanerud so can we close this issue ?

@Aanerud
Copy link

Aanerud commented Dec 30, 2019 via email

@yonzhan yonzhan removed this from the S164 milestone Feb 1, 2020
@yonzhan yonzhan added this to the S165 milestone Feb 1, 2020
@yonzhan yonzhan modified the milestones: S165, S166 Feb 15, 2020
@jiasli
Copy link
Member

jiasli commented Feb 25, 2020

According to the doc of subprocess.check_output, please use stderr=None to discard stderr.

@jiasli jiasli closed this as completed Feb 25, 2020
@jiasli
Copy link
Member

jiasli commented Mar 24, 2020

As an alternative, we have added option --only-show-errors in #12604 to disable warnings that are written to stderr. It will be included in S167 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core CLI core infrastructure Storage az storage
Projects
None yet
Development

No branches or pull requests

6 participants