Is your feature request related to a problem? Please describe.
When using a custom cloud, we explicitly have to inject the correct endpoint URL into the Management Clients. This leads to a lot of duplication, and also means awkward if/else statements when we do want to switch back to the Azure Public Cloud.
As an example, this is what the SQL client currently looks like:
|
base_url: str = "https://management.azure.com", |
Which means that an implementation would always have to jump through hoops to configure this:
base_url = "customcloud.company.com"
kwargs = use_custom_cloud() ? {"base_url": base_url} : {}
client = SQLClient(**kwargs)
...
(Our implementation doesn't actually look like this - this is just simplified to make the point.)
Describe the solution you'd like
The ability to set a global environment variable that every client listens to.
AZURE_ENDPOINT_URL=http://customcloud.company.com
The Python clients we can use this if no explicit base_url is configured:
class SqlManagementClientConfiguration
def __init__(
...
base_url: Optional[str] = None,
):
self.base_url = base_url or os.environ.get("AZURE_ENDPOINT_URL") or "https://management.azure.com"
Is your feature request related to a problem? Please describe.
When using a custom cloud, we explicitly have to inject the correct endpoint URL into the Management Clients. This leads to a lot of duplication, and also means awkward if/else statements when we do want to switch back to the Azure Public Cloud.
As an example, this is what the SQL client currently looks like:
azure-sdk-for-python/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_configuration.py
Line 48 in 9405eb1
Which means that an implementation would always have to jump through hoops to configure this:
(Our implementation doesn't actually look like this - this is just simplified to make the point.)
Describe the solution you'd like
The ability to set a global environment variable that every client listens to.
The Python clients we can use this if no explicit
base_urlis configured: