1

I am making a rest call using AzCli to get the backup configuration of the web apps. However there are couple of scenarios which I want to consider while making this REST call.

To get the state of the request made I am trying to get the response code for it. In the documentation Microsoft says there are two responses 200 OK and other status code are available. I am not sure how can I get status code response after making REST call. I am not sure its possible to get the response code through AzCli , if no then please suggest alternatives. Any help would be appreciated.

Environment

Windows-10-10.0.19041-SP0
Python 3.8.9
Installer: MSI

azure-cli 2.24.0 *

Extensions:
logic 0.1.3
url=f"https://management.azure.com/subscriptions/{sub_id}/resourceGroups/{resourceGroup}/providers/Microsoft.Web/sites/{resourceName}/config/backup/list?api-version=2019-08-01"

   cliResult = self.azure_cli_v2(["rest", "--method", "post", "--url", url], log_args=False)

1 Answer 1

0

You could call REST API with --verbose to increase logging verbosity.

My test command to get subscription:

url = "https://management.azure.com/subscriptions/{subscription-id}?api-version=2020-01-01"
access_token = $(az account get-access-token --resource https://management.azure.com/ --query accessToken -o tsv)
headers = "Authorization=Bearer "+$access_token
az rest --method get --uri $url --headers $headers --verbose

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.