Skip to content

Commit

Permalink
azure_region china support
Browse files Browse the repository at this point in the history
  • Loading branch information
tayganr committed Nov 12, 2023
1 parent 58b1720 commit f9aa516
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions purviewcli/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def set_region(self,app):
if self.azure_region is None:
self.management_endpoint= "https://management.azure.com"
self.purview_endpoint = "purview.azure.com"
elif self.azure_region.lower() == "china":
elif self.azure_region is not None and self.azure_region.lower() == "china":
self.management_endpoint= "https://management.chinacloudapi.cn"
self.purview_endpoint = "purview.azure.cn"
else:
Expand All @@ -44,22 +44,22 @@ def set_account(self, app):
\tmacOS (Terminal):\t\texport PURVIEW_NAME=value
\tPython:\t\t\t\tos.environ["PURVIEW_NAME"] = "value"
\tPowerShell:\t\t\t$env:PURVIEW_NAME = "value"
\tJupyter Notebook:\t\t%env PURVIEW_NAME=value
\tJupyter Notebook:\t\t%env PURVIEW_NAME=value
Alternatively, an Azure Purview account name can be provided by appending --purviewName=<val> at the end of your command.
""")
sys.exit()
sys.exit()

def set_token(self, app):
if self.azure_region.lower() == "china":
if self.azure_region is not None and self.azure_region.lower() == "china":
credential = DefaultAzureCredential(authority="https://login.partner.microsoftonline.cn",exclude_shared_token_cache_credential=True)
else:
credential = DefaultAzureCredential(exclude_shared_token_cache_credential=True)

if app == "management":
resource = self.management_endpoint + "/.default"
resource = self.management_endpoint + "/.default"
else:
resource = "https://purview.azure.net/.default"
resource = "https://purview.azure.net/.default"

try:
token = credential.get_token(f'{resource}')
Expand Down Expand Up @@ -98,7 +98,7 @@ def http_get(self, app, method, endpoint, params, payload, files, headers):

try:
response = requests.request(method, uri, params=params, json=payload, files=files, headers=headers)
#DEBUG
# DEBUG
# print(f"Method:\t\t{method}")
# print(f"Body:\t\t{payload}")
# print(f"Headers:\t\t{headers}")
Expand Down

0 comments on commit f9aa516

Please sign in to comment.