From 2d146ab9dbd3fb859930a19eeba2415f1afa9bd6 Mon Sep 17 00:00:00 2001 From: Simon Kurtz Date: Fri, 30 May 2025 07:16:33 -0400 Subject: [PATCH 1/3] Add support for AFD --- samples/authX/create.ipynb | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/samples/authX/create.ipynb b/samples/authX/create.ipynb index a7f5dad..3bb7539 100644 --- a/samples/authX/create.ipynb +++ b/samples/authX/create.ipynb @@ -190,14 +190,25 @@ "from apimjwt import JwtPayload, SymmetricJwtToken\n", "from apimtypes import HR_MEMBER_ROLE_ID, HR_ADMINISTRATOR_ROLE_ID, HR_ASSOCIATE_ROLE_ID\n", "\n", + "# 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", + "endpoint_url = apim_gateway_url\n", + "utils.print_message('Checking if the infrastructure architecture deployment uses Azure Front Door.', blank_above = True)\n", + "afd_endpoint_url = utils.get_frontdoor_url(deployment, rg_name)\n", + "\n", + "if afd_endpoint_url:\n", + " endpoint_url = afd_endpoint_url\n", + " utils.print_message(f'Using Azure Front Door URL: {afd_endpoint_url}', blank_above = True)\n", + "else:\n", + " utils.print_message(f'Using APIM Gateway URL: {apim_gateway_url}', blank_above = True)\n", + "\n", "# 1) HR Administrator\n", "# Create a JSON Web Token with a payload and sign it with the symmetric key from above.\n", "jwt_payload_hr_admin = JwtPayload(subject = 'user123', name = 'Angie Administrator', roles = [HR_MEMBER_ROLE_ID, HR_ADMINISTRATOR_ROLE_ID])\n", "encoded_jwt_token_hr_admin = SymmetricJwtToken(jwt_key_value, jwt_payload_hr_admin).encode()\n", - "print(f'JWT token HR Admin: {encoded_jwt_token_hr_admin}') # this value is used to call the APIs via APIM\n", + "print(f'\\nJWT token HR Admin: {encoded_jwt_token_hr_admin}') # this value is used to call the APIs via APIM\n", "\n", "# Set up an APIM requests object with the JWT token\n", - "reqsApimAdmin = ApimRequests(apim_gateway_url)\n", + "reqsApimAdmin = ApimRequests(endpoint_url)\n", "reqsApimAdmin.headers['Authorization'] = f'Bearer {encoded_jwt_token_hr_admin}'\n", "\n", "# Call APIM\n", @@ -208,10 +219,10 @@ "# Create a JSON Web Token with a payload and sign it with the symmetric key from above.\n", "jwt_payload_hr_associate = JwtPayload(subject = 'user789', name = 'Aaron Associate', roles = [HR_MEMBER_ROLE_ID, HR_ASSOCIATE_ROLE_ID])\n", "encoded_jwt_token_hr_associate = SymmetricJwtToken(jwt_key_value, jwt_payload_hr_associate).encode()\n", - "print(f'\\n\\nJWT token HR Associate: {encoded_jwt_token_hr_associate}') # this value is used to call the APIs via APIM\n", + "print(f'\\nJWT token HR Associate: {encoded_jwt_token_hr_associate}') # this value is used to call the APIs via APIM\n", "\n", "# Set up an APIM requests object with the JWT token\n", - "reqsApimAssociate = ApimRequests(apim_gateway_url)\n", + "reqsApimAssociate = ApimRequests(endpoint_url)\n", "reqsApimAssociate.headers['Authorization'] = f'Bearer {encoded_jwt_token_hr_associate}'\n", "\n", "# Call APIM\n", From 9d14eb0b5c545d9d579216c69b13400120fdaa58 Mon Sep 17 00:00:00 2001 From: Simon Kurtz Date: Fri, 30 May 2025 07:16:40 -0400 Subject: [PATCH 2/3] Format --- infrastructure/simple-apim/create.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infrastructure/simple-apim/create.ipynb b/infrastructure/simple-apim/create.ipynb index b76d985..80acba0 100644 --- a/infrastructure/simple-apim/create.ipynb +++ b/infrastructure/simple-apim/create.ipynb @@ -74,8 +74,8 @@ "\n", "# 1) Define the Bicep parameters with serialized APIs\n", "bicep_parameters = {\n", - " 'apimSku': {'value': apim_sku.value},\n", - " 'apis': {'value': [api.to_dict() for api in apis]}\n", + " 'apimSku' : {'value': apim_sku.value},\n", + " 'apis' : {'value': [api.to_dict() for api in apis]}\n", "}\n", "\n", "# 2) Run the deployment\n", From 2950e5893322db28ce11cbe21f54a0150fac2a2e Mon Sep 17 00:00:00 2001 From: Simon Kurtz Date: Fri, 30 May 2025 07:17:17 -0400 Subject: [PATCH 3/3] Add runtime --- samples/authX/create.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/authX/create.ipynb b/samples/authX/create.ipynb index 3bb7539..33d3158 100644 --- a/samples/authX/create.ipynb +++ b/samples/authX/create.ipynb @@ -10,7 +10,7 @@ "\n", "⚙️ **Supported infrastructures**: All infrastructures\n", "\n", - "⌚ **Expected *Run All* runtime (excl. infrastructure prerequisite): ~[NOTEBOOK RUNTIME] minute**\n", + "⌚ **Expected *Run All* runtime (excl. infrastructure prerequisite): ~2-3 minutes**\n", "\n", "## Objectives\n", "\n",