Azure / msrest-for-python

The runtime library "msrest" for AutoRest generated Python clients.
MIT License
41 stars 64 forks source link

'x-ms-failure-cause': 'gateway' in MCD 'x-ms-routing-request-id': 'WESTEUROPE' cause Response status: 404 #80

Closed the1bit closed 6 years ago

the1bit commented 6 years ago

Hi,

I would like to manage the Azure subscription related metrics and alerts from Python. I have started the discovering of capabilities of this area and I am facing a serious issue.

I work in MCD (Microsoft Cloud Deutschland).

When I create Monitor client client = MonitorManagementClient(credentials,subscription_id) it seems everything is OK. Then I want to make a request something like this: metrics_data = client.metrics.list(resource_id, timespan="{}/{}".format(yesterday, today), interval='PT1H', metric='Percentage CPU', aggregation='Total') I get an error message: "Operation returned an invalid status code 'Not Found' raise models.ErrorResponseException(self._deserialize, response)"

I tried to change the authentication to Adal but the result was same. Then I turned on the debug logging to msrest (logging.getLogger('msrest').setLevel(logging.DEBUG);) and i checked the result and I saw this line: DEBUG:msrest.http_logger: 'x-ms-routing-request-id': 'WESTEUROPE:20180111T155250Z:...' This is strange for me in MCD. This line should be GERMANYCENTRAL or GERMANYNORTHEAST.

Then I tried my code in MCI and it worked. I turned on the debug logging to msrest there and I saw the line is totally same: DEBUG:msrest.http_logger: 'x-ms-routing-request-id': 'WESTEUROPE:20180111T165801Z:...'

Accordiongly I guess something is wrong here. I would like to ask sour support in this situation.

Here is the code: from azure.common.credentials import UserPassCredentials; from azure.mgmt.monitor import MonitorManagementClient; from azure.mgmt.monitor.models import RuleMetricDataSource; from azure.mgmt.monitor.models import ThresholdRuleCondition; from azure.mgmt.monitor.models import RuleEmailAction; from msrestazure.azure_cloud import AZURE_GERMAN_CLOUD as cloud_environment;

credentials = UserPassCredentials(username=os.environ.get('AZURE_USER', input('Username: ')),password=os.environ.get('AZURE_PASSWORD', getpass.getpass('Password: ')), tenant=os.environ.get('AZURE_TENANT_ID', input('Tenant (AD Identifier): ')), cloud_environment=cloud_environment );

client = MonitorManagementClient(credentials,subscription_id);

metrics_data = client.metrics.list(resource_id, timespan="{}/{}".format(yesterday, today), interval='PT1H', metric='Percentage CPU', aggregation='Total');

Versions: msrest==0.4.25 msrestazure==0.4.20

Thank you for your help in this matter.

Feel free to get in touch with any further questions.

Best Regards, Tibor

the1bit commented 6 years ago

Issue has been fixed. https://github.com/Azure/azure-sdk-for-python/issues/1780