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 rest response code #10714

Closed
jurgyy opened this issue Oct 1, 2019 · 8 comments · Fixed by #12117
Closed

az rest response code #10714

jurgyy opened this issue Oct 1, 2019 · 8 comments · Fixed by #12117
Assignees
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. rest az rest
Milestone

Comments

@jurgyy
Copy link
Contributor

jurgyy commented Oct 1, 2019

Is your feature request related to a problem? Please describe.
Currently when making put or patch requests using az rest it can be unclear whether the request is executed successfully. Unsuccessful execution returns an error, but there are certain commands that have multiple successful responses such as api create/update: codes 200, 201 and 202. In this case getting no returned value is confusing as to what has happened.

Describe the solution you'd like
It would be nice if az rest was able to return those codes to ease the flow of scripts.

Describe alternatives you've considered
In the current scenario I have to send a get request to check if everything is set as expected while this information is (sometimes) already present in the response header so perhaps return the header entirely.

@maggiepint maggiepint added customer-reported Issues that are reported by GitHub users external to the Azure organization. rest az rest Service Attention This issue is responsible by Azure service team. labels Oct 2, 2019
@maggiepint
Copy link

Hi,
I've routed this to the appropriate team for follow-up.

@haroldrandom haroldrandom added customer-reported Issues that are reported by GitHub users external to the Azure organization. rest az rest Service Attention This issue is responsible by Azure service team. labels Oct 25, 2019
@mattgwic
Copy link

mattgwic commented Dec 4, 2019

It should at least show up when I use --debug

@jurgyy
Copy link
Contributor Author

jurgyy commented Feb 4, 2020

Any update on this?

I've just spend the past hour debugging a problem with trying to create an API and the source of the problem was that in the Swagger specification the property properties.value.info.title was identical to an already existing API. Sending the request manually I got a 202 Accepted response with a location url in the header which when I send a GET request I received the following message:

{
	"error": {
		"code": "ValidationError",
		"message": "One or more fields contain incorrect values:",
		"details": [{
				"code": "ValidationError",
				"target": "name",
				"message": "API with specified name 'myApiName' already exists"
			}
		]
	}
}

Would've been nice if az rest returns something along those lines...

e: note that az rest returned no response or anything. Running it with --debug ended with az_command_data_logger : exit code: 0 so not useful at all.

@yonzhan yonzhan added this to the S165 milestone Feb 4, 2020
@zhoxing-ms
Copy link
Contributor

This issue is related to asynchronous operation, asynchronous execution will be adopted for some time-consuming operations.
Usage documents of asynchronous API: link

@zhoxing-ms
Copy link
Contributor

@jurgyy What do you expect to return? Is the location URL returned when you manually request to create the API or the ValidationError returned when you send a GET request for the second time?

@jurgyy
Copy link
Contributor Author

jurgyy commented Feb 7, 2020

@zhoxing-ms Due to the asynchronous nature of the problem I'd suppose the location URL would suffice and let the end user decide what to do with it. But not returning anything is undesired behavior in my opinion.

@zhoxing-ms
Copy link
Contributor

zhoxing-ms commented Feb 7, 2020

@jurgyy OK, I will submit a PR to fix it. After that, you can get information about the header by using --debug, such as the location URL.

@jiasli
Copy link
Member

jiasli commented Mar 20, 2020

We have changed the behavior in PR #12117 for --verbose log (including --debug) to show more information as other commands do (like az group show --debug).

Request URL: 'https://management.azure.com/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourcegroups/myrg?api-version=2019-07-01'
Request method: 'GET'
Request headers:
    'User-Agent': 'AZURECLI/2.2.0'
    'Accept-Encoding': 'gzip, deflate'
    'Accept': '*/*'
    ...
Request body:
None
Response status: 200
Response headers:
    'Cache-Control': 'no-cache'
    'Pragma': 'no-cache'
    'Content-Type': 'application/json; charset=utf-8'
    'Content-Encoding': 'gzip'
    ...
Response content:
{"id":"/subscriptions/0b1f6...

For including raw http information in the response body from stdout, I have a proposal at #12117 (comment). It would be great if anyone can share some suggestions. 😃

@jiasli jiasli self-assigned this Mar 20, 2020
@jiasli jiasli removed the Service Attention This issue is responsible by Azure service team. label Mar 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. rest az rest
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants