Skip to content

Commit

Permalink
deprecate azure_germany (#37654)
Browse files Browse the repository at this point in the history
* deprecate azure_germany

* update

* update

* Update sdk/identity/azure-identity/azure/identity/_constants.py

Co-authored-by: Paul Van Eck <[email protected]>

* update

---------

Co-authored-by: Paul Van Eck <[email protected]>
  • Loading branch information
xiangyan99 and pvaneck authored Oct 4, 2024
1 parent b5792ad commit 37a2e61
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 8 deletions.
2 changes: 2 additions & 0 deletions sdk/identity/azure-identity/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

### Other Changes

- Deprecated `AzureAuthorityHosts.AZURE_GERMANY`

## 1.18.0 (2024-09-19)

### Features Added
Expand Down
16 changes: 14 additions & 2 deletions sdk/identity/azure-identity/azure/identity/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
import warnings

DEVELOPER_SIGN_ON_CLIENT_ID = "04b07795-8ddb-461a-bbee-02f9e1bf7b46"
AZURE_VSCODE_CLIENT_ID = "aebc6443-996d-45c2-90f0-388ff96faa56"
Expand All @@ -13,9 +14,20 @@
CACHE_CAE_SUFFIX = ".cae"


class AzureAuthorityHosts:
class AzureAuthorityHostsMeta(type):
def __getattr__(cls, name):
if name == "AZURE_GERMANY":
warnings.warn(
"AZURE_GERMANY is deprecated. Microsoft Cloud Germany was closed on October 29th, 2021.",
DeprecationWarning,
stacklevel=2,
)
return "login.microsoftonline.de"
raise AttributeError(f"{name} not found in {cls.__name__}")


class AzureAuthorityHosts(metaclass=AzureAuthorityHostsMeta):
AZURE_CHINA = "login.chinacloudapi.cn"
AZURE_GERMANY = "login.microsoftonline.de"
AZURE_GOVERNMENT = "login.microsoftonline.us"
AZURE_PUBLIC_CLOUD = "login.microsoftonline.com"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ def _initialize(self, vscode_user_settings: Dict, **kwargs: Any) -> None:
authority = AzureAuthorityHosts.AZURE_PUBLIC_CLOUD
elif self._cloud == "AzureChinaCloud":
authority = AzureAuthorityHosts.AZURE_CHINA
elif self._cloud == "AzureGermanCloud":
authority = AzureAuthorityHosts.AZURE_GERMANY
elif self._cloud == "AzureUSGovernment":
authority = AzureAuthorityHosts.AZURE_GOVERNMENT
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

_DEFAULT_AUTHENTICATE_SCOPES = {
"https://" + KnownAuthorities.AZURE_CHINA: ("https://management.core.chinacloudapi.cn//.default",),
"https://" + KnownAuthorities.AZURE_GERMANY: ("https://management.core.cloudapi.de//.default",),
"https://" + KnownAuthorities.AZURE_GOVERNMENT: ("https://management.core.usgovcloudapi.net//.default",),
"https://" + KnownAuthorities.AZURE_PUBLIC_CLOUD: ("https://management.core.windows.net//.default",),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ def validate_scopes(*scopes, **_):
"authority,expected_scope",
(
(KnownAuthorities.AZURE_CHINA, "https://management.core.chinacloudapi.cn//.default"),
(KnownAuthorities.AZURE_GERMANY, "https://management.core.cloudapi.de//.default"),
(KnownAuthorities.AZURE_GOVERNMENT, "https://management.core.usgovcloudapi.net//.default"),
(KnownAuthorities.AZURE_PUBLIC_CLOUD, "https://management.core.windows.net//.default"),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ def test_custom_cloud_no_authority():
(
("AzureCloud", AzureAuthorityHosts.AZURE_PUBLIC_CLOUD),
("AzureChinaCloud", AzureAuthorityHosts.AZURE_CHINA),
("AzureGermanCloud", AzureAuthorityHosts.AZURE_GERMANY),
("AzureUSGovernment", AzureAuthorityHosts.AZURE_GOVERNMENT),
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ async def test_custom_cloud_no_authority():
(
("AzureCloud", AzureAuthorityHosts.AZURE_PUBLIC_CLOUD),
("AzureChinaCloud", AzureAuthorityHosts.AZURE_CHINA),
("AzureGermanCloud", AzureAuthorityHosts.AZURE_GERMANY),
("AzureUSGovernment", AzureAuthorityHosts.AZURE_GOVERNMENT),
),
)
Expand Down

0 comments on commit 37a2e61

Please sign in to comment.