Skip to content

Commit c4b25a2

Browse files
Add test_url_preflight_check
1 parent 77b69ef commit c4b25a2

File tree

5 files changed

+20
-37
lines changed

5 files changed

+20
-37
lines changed

samples/authX-pro/create.ipynb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -231,15 +231,7 @@
231231
"from authfactory import AuthFactory\n",
232232
"\n",
233233
"# Preflight: Check if the infrastructure architecture deployment uses Azure Front Door. If so, assume that APIM is not directly accessible and use the Front Door URL instead.\n",
234-
"endpoint_url = apim_gateway_url\n",
235-
"utils.print_message('Checking if the infrastructure architecture deployment uses Azure Front Door.', blank_above = True)\n",
236-
"afd_endpoint_url = utils.get_frontdoor_url(deployment, rg_name)\n",
237-
"\n",
238-
"if afd_endpoint_url:\n",
239-
" endpoint_url = afd_endpoint_url\n",
240-
" utils.print_message(f'Using Azure Front Door URL: {afd_endpoint_url}', blank_above = True)\n",
241-
"else:\n",
242-
" utils.print_message(f'Using APIM Gateway URL: {apim_gateway_url}', blank_above = True)\n",
234+
"endpoint_url = utils.test_url_preflight_check(deployment, rg_name, apim_gateway_url)\n",
243235
"\n",
244236
"# 1) HR Administrator\n",
245237
"# Create a JSON Web Token with a payload and sign it with the symmetric key from above.\n",

samples/authX/create.ipynb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,7 @@
193193
"from authfactory import AuthFactory\n",
194194
"\n",
195195
"# Preflight: Check if the infrastructure architecture deployment uses Azure Front Door. If so, assume that APIM is not directly accessible and use the Front Door URL instead.\n",
196-
"endpoint_url = apim_gateway_url\n",
197-
"utils.print_message('Checking if the infrastructure architecture deployment uses Azure Front Door.', blank_above = True)\n",
198-
"afd_endpoint_url = utils.get_frontdoor_url(deployment, rg_name)\n",
199-
"\n",
200-
"if afd_endpoint_url:\n",
201-
" endpoint_url = afd_endpoint_url\n",
202-
" utils.print_message(f'Using Azure Front Door URL: {afd_endpoint_url}', blank_above = True)\n",
203-
"else:\n",
204-
" utils.print_message(f'Using APIM Gateway URL: {apim_gateway_url}', blank_above = True)\n",
196+
"endpoint_url = utils.test_url_preflight_check(deployment, rg_name, apim_gateway_url)\n",
205197
"\n",
206198
"# 1) HR Administrator\n",
207199
"# Create a JSON Web Token with a payload and sign it with the symmetric key from above.\n",

samples/load-balancing/create.ipynb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,7 @@
156156
" time.sleep(sleep_in_s) # Wait a bit before the next set of calls to allow for the backend timeouts to reset\n",
157157
"\n",
158158
"# Preflight: Check if the infrastructure architecture deployment uses Azure Front Door. If so, assume that APIM is not directly accessible and use the Front Door URL instead.\n",
159-
"utils.print_message('Checking if the infrastructure architecture deployment uses Azure Front Door.', blank_above = True)\n",
160-
"afd_endpoint_url = utils.get_frontdoor_url(deployment, rg_name)\n",
161-
"\n",
162-
"if afd_endpoint_url:\n",
163-
" reqs = ApimRequests(afd_endpoint_url)\n",
164-
" utils.print_message(f'Using Azure Front Door URL: {afd_endpoint_url}', blank_above = True)\n",
165-
"else:\n",
166-
" reqs = ApimRequests(apim_gateway_url)\n",
167-
" utils.print_message(f'Using APIM Gateway URL: {apim_gateway_url}', blank_above = True)\n",
159+
"endpoint_url = utils.test_url_preflight_check(deployment, rg_name, apim_gateway_url)\n",
168160
"\n",
169161
"# 1) Prioritized API calls\n",
170162
"utils.print_message('1/4: Starting API calls for prioritized distribution (50/50)')\n",

samples/secure-blob-access/create.ipynb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -293,15 +293,7 @@
293293
"\n",
294294
"\n",
295295
"# Preflight: Check if the infrastructure architecture deployment uses Azure Front Door\n",
296-
"endpoint_url = apim_gateway_url\n",
297-
"utils.print_message('Checking if the infrastructure architecture deployment uses Azure Front Door.', blank_above = True)\n",
298-
"afd_endpoint_url = utils.get_frontdoor_url(deployment, rg_name)\n",
299-
"\n",
300-
"if afd_endpoint_url:\n",
301-
" endpoint_url = afd_endpoint_url\n",
302-
" utils.print_message(f'Using Azure Front Door URL: {afd_endpoint_url}', blank_above = True)\n",
303-
"else:\n",
304-
" utils.print_message(f'Using APIM Gateway URL: {apim_gateway_url}', blank_above = True)\n",
296+
"endpoint_url = utils.test_url_preflight_check(deployment, rg_name, apim_gateway_url)\n",
305297
"\n",
306298
"# 1) Test with authorized user (has blob access role)\n",
307299
"utils.print_message('1) Testing with Authorized User', blank_above = True)\n",

shared/python/utils.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,6 @@ def check_apim_blob_permissions(apim_name: str, storage_account_name: str, resou
829829

830830
return False
831831

832-
833832
def wait_for_apim_blob_permissions(apim_name: str, storage_account_name: str, resource_group_name: str, max_wait_minutes: int = 15) -> bool:
834833
"""
835834
Wait for APIM's managed identity to have Storage Blob Data Reader permissions on the storage account.
@@ -858,3 +857,19 @@ def wait_for_apim_blob_permissions(apim_name: str, storage_account_name: str, re
858857
print("")
859858

860859
return success
860+
861+
def test_url_preflight_check(deployment: INFRASTRUCTURE, rg_name: str, apim_gateway_url: str) -> str:
862+
# Preflight: Check if the infrastructure architecture deployment uses Azure Front Door. If so, assume that APIM is not directly accessible and use the Front Door URL instead.
863+
864+
print_message('Checking if the infrastructure architecture deployment uses Azure Front Door.', blank_above = True)
865+
866+
afd_endpoint_url = get_frontdoor_url(deployment, rg_name)
867+
868+
if afd_endpoint_url:
869+
endpoint_url = afd_endpoint_url
870+
print_message(f'Using Azure Front Door URL: {afd_endpoint_url}', blank_above = True)
871+
else:
872+
endpoint_url = apim_gateway_url
873+
print_message(f'Using APIM Gateway URL: {apim_gateway_url}', blank_above = True)
874+
875+
return endpoint_url

0 commit comments

Comments
 (0)