chaostoolkit-incubator / chaostoolkit-azure

Chaos Toolkit Extension for Azure
https://chaostoolkit.org/
Apache License 2.0
22 stars 28 forks source link

Support Azure China or multiple region. #70

Closed xpdable closed 4 years ago

xpdable commented 4 years ago

We work in Azure China, so the current login with cred settings will always fail as the base_url of each client is None and then default to msrestazure.azure_cloud.AZURE_PUBLIC_CLOUD. Therefore our Azure China credential will failed. You can see the login url is direct to the global one.

[2019-09-18 17:58:13 ERROR] => failed: msrest.exceptions.AuthenticationError: , AdalError: Get Token request returned http error: 400 and server response: {"error":"invalid_request","error_description":"AADSTS90002: Tenant 'adsfadfa' not found. This may happen if there are no active subscriptions for the tenant. Check with your subscription administrator.\r\nTrace ID: adsfadsf\r\nCorrelation ID: dadfadfa\r\nTimestamp: 2019-09-18 09:58:13Z","error_codes":[90002],"timestamp":"2019-09-18 09:58:13Z","trace_id":"dddddd","correlation_id":"xxxxxxxxx","error_uri":"https://login.microsoftonline.com/error?code=90002"}

By checking Azure python SDK, we've successfully point the China Azure URL as below, but it is not a good solution that I have to modify each py where a client is declared and concurrent. E.g.

from msrestazure.azure_cloud import AZURE_CHINA_CLOUD
...
def __compute_mgmt_client(secrets, configuration):
    with auth(secrets) as cred:
        subscription_id = configuration['azure']['subscription_id']
        client = ComputeManagementClient(
            credentials=cred, subscription_id=subscription_id, 
            base_url=AZURE_CHINA_CLOUD.endpoints.resource_manager)

        return client
...

Furthermore, shall we manage to set the configuration from configuration in order to enable more choice of the Azure Cloud? image

xpdable commented 4 years ago

An idea I could see is, the cloud name could be set in configuration some how. And for each client declaration, then we have to pass something like base_url=configuration[CLOUD_NAME]

buderre commented 4 years ago

I think this one can be closed @xpdable ?

xpdable commented 4 years ago

This function has been merged PR #71