<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Feature Idea</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">contrib/inventory/azure_rm.py<br>
lib/ansible/module_utils/azure_rm_common.py</p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<p dir="auto">New feature - latest</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">Not all Azure cloud are public azure with endpoint to '<a href="https://management.azure.com/" rel="nofollow">https://management.azure.com/</a>'<br>
For instance:</p>
<ul dir="auto">
<li>Azure China: '<a href="https://management.chinacloudapi.cn/" rel="nofollow">https://management.chinacloudapi.cn/</a>'</li>
<li>Gov Azure: '<a href="https://management.usgovcloudapi.net/" rel="nofollow">https://management.usgovcloudapi.net/</a>'</li>
<li>German Azure: '<a href="https://management.microsoftazure.de/" rel="nofollow">https://management.microsoftazure.de/</a>'</li>
</ul>
<p dir="auto">Currently the azure_rm module provides no possibility to do configure that. This has to be done at two place:</p>
<ul dir="auto">
<li>Inside the authentication ServicePrincipalCredentials or UserPassCredentials by adding `resource="endpoint"</li>
<li>Inside the client by using base_url parameter</li>
</ul>
<p dir="auto">Example:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="endpoint = 'https://management.usgovcloudapi.net/'
self.azure_credentials = UserPassCredentials(
    self.credentials['ad_user'],
    self.credentials['password'],
    resource=endpoint
)
self._compute_client = ComputeManagementClient(
    self.azure_credentials,
    self.subscription_id,
    base_url=endpoint
)"><pre class="notranslate"><span class="pl-s1">endpoint</span> <span class="pl-c1">=</span> <span class="pl-s">'https://management.usgovcloudapi.net/'</span>
<span class="pl-s1">self</span>.<span class="pl-s1">azure_credentials</span> <span class="pl-c1">=</span> <span class="pl-v">UserPassCredentials</span>(
    <span class="pl-s1">self</span>.<span class="pl-s1">credentials</span>[<span class="pl-s">'ad_user'</span>],
    <span class="pl-s1">self</span>.<span class="pl-s1">credentials</span>[<span class="pl-s">'password'</span>],
    <span class="pl-s1">resource</span><span class="pl-c1">=</span><span class="pl-s1">endpoint</span>
)
<span class="pl-s1">self</span>.<span class="pl-s1">_compute_client</span> <span class="pl-c1">=</span> <span class="pl-v">ComputeManagementClient</span>(
    <span class="pl-s1">self</span>.<span class="pl-s1">azure_credentials</span>,
    <span class="pl-s1">self</span>.<span class="pl-s1">subscription_id</span>,
    <span class="pl-s1">base_url</span><span class="pl-c1">=</span><span class="pl-s1">endpoint</span>
)</pre></div>
<p dir="auto">Code MUST check that endpoint is ending with a /, since this is requirement from AD and you will get an invalid token otherwise. Should be done at the SDK level, but it's not done for now, so double-check here is safer.</p>
<p dir="auto">I'll try to do a PR asap, just wanted to track this down.</p>
<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Feature Idea</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">azure_rm_common.py</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">The current definition of the azure_rm common module utils doesn't allow overriding the various built-in endpoints (auth, table/blob storage, service bus, etc). This will be necessary to allow connection to other Azure instances (eg, AzureChinaCloud, private Azure Stack instances).</p>
<p dir="auto">The new Python SDK seems to support overriding the endpoints via host_base, so we should add the override capability to the env credential mapping and common module utility code.</p>
<p dir="auto">List of AzureChinaCloud endpoint URLs is at: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="57563350" data-permission-text="Title is private" data-url="https://github.com/Azure/azure-sdk-for-python/issues/284" data-hovercard-type="issue" data-hovercard-url="/Azure/azure-sdk-for-python/issues/284/hovercard" href="https://github.com/Azure/azure-sdk-for-python/issues/284">Azure/azure-sdk-for-python#284</a></p>