-
Notifications
You must be signed in to change notification settings - Fork 105
Update API Proxy to Serverless Section #158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,106 +1,134 @@ | ||||||||||||||||||||||
| --- | ||||||||||||||||||||||
| title: API Proxy to Serverless | ||||||||||||||||||||||
| parent: Additional Topics | ||||||||||||||||||||||
| has_children: false | ||||||||||||||||||||||
| nav_order: 3 | ||||||||||||||||||||||
| --- | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ## API Proxy to Serverless | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Azure Serverless (Functions and Logic Apps) can be configured to benefit from the advantages of Azure API Management. | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ### Azure Functions | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - Create a simple function that is Triggered by an HTTP Request | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Example: | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|  | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ```c# | ||||||||||||||||||||||
| //string[] strColors = { "blue", "lightblue", "darkblue" }; | ||||||||||||||||||||||
| string[] strColors = { "green", "lightgreen", "darkgreen" }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Random r = new Random(); | ||||||||||||||||||||||
| int rInt = r.Next(strColors.Length); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| return (ActionResult)new OkObjectResult(strColors[rInt]); | ||||||||||||||||||||||
| ``` | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Lets add the function to Azure API Management. In the API blade select [+Add API] and the [Function App] tile | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|  | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - Select the [Browse] button to get a list of Functions in the subscription | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|  | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - Select the Function App and then the Function | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|  | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|  | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - Amend the Names / Descriptions, URL suffix and select the Products | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|  | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - As previously add CORS policy | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - Validate the function works - either from the Azure management portal or the developer portal | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|  | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|  | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ### Azure Logic Apps | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - Create a simple logic app that is Triggered by an HTTP Request | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Example: | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|  | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|  | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Use the following sample message to generate the schema of the Request body payload. By specifying the schema, the individual fields (in this case `msg`) can be extracted and referred to in the subsequent logic | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ```json | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| "msg": "text" | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| ``` | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Lets add the function to API Managament. In the API blade select [+Add API] and the [Logic App] tile | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|  | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - Select the [Browse] button to get a list of Logic Apps in the subscription | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|  | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - Select the Logic App | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|  | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - Amend the Names / Descriptions, URL suffix and select the Products | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|  | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| As previously add CORS policy | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - Validate the Logic App works - either from the Azure management portal or the developer poral | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|  | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|  | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - Check the Logic App audit | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|  | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - Check the email was sent | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|  | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| --- | ||||||||||||||||||||||
| title: API Proxy to Serverless | ||||||||||||||||||||||
| parent: Additional Topics | ||||||||||||||||||||||
| has_children: false | ||||||||||||||||||||||
| nav_order: 3 | ||||||||||||||||||||||
| --- | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ## API Proxy to Serverless | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Azure Serverless (Functions and Logic Apps) can be configured to benefit from the advantages of Azure API Management. | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ### Azure Functions | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| In this section, we will create a simple HTTP Triggered Azure Function which runs on the [Flex Consumption](https://learn.microsoft.com/en-us/azure/azure-functions/flex-consumption-plan) plan. Flex Consumption is a Linux-based Azure Functions hosting plan that uses a serverless billing model and provides private networking, flexible memory size allocation and fast scale-out capabilities. | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - Create a simple function that is Triggered by an HTTP Request. Navigate to the **Azure Functions** portal and click **Create**. | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|  | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - In the **Create Azure Function** screen, select **Flex Consumption**. | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|  | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - On the **Basics** properties screen, fill in the details as follows: | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - **Resource Group (create new)**: `af-dev-we-apimazf-[your-initials]-01` | ||||||||||||||||||||||
| - **Function App Name**: `APIMAZF` | ||||||||||||||||||||||
| - **Region**: `West Europe` | ||||||||||||||||||||||
| - **Runtime stack**: `3.12` | ||||||||||||||||||||||
|
||||||||||||||||||||||
| - **Runtime stack**: `3.12` | |
| - **Runtime stack**: `Python` | |
| - **Version**: `3.12` |
Copilot
AI
Apr 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The suggested Function App name APIMAZF is likely to fail for learners: Function App names must be globally unique (DNS name) and are typically lowercase. Consider using a placeholder that includes initials and/or a random suffix (e.g., apimazf-[your-initials]-[unique]) and keeping the casing consistent with Azure’s naming rules.
Copilot
AI
Feb 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 43 contains a bullet list inside another bullet item (line 42). The nested commands should be properly indented with two spaces to maintain correct markdown list hierarchy and rendering. Currently, the indentation may not render correctly in all markdown parsers.
Copilot
AI
Apr 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function naming is inconsistent (HttpExample in the CLI command vs HTTPExample in the portal text). Since Azure Functions are case-sensitive in code references and route paths, please standardize the casing throughout (function name, route, and screenshots) so learners don’t end up looking for the wrong function.
| - The function will take a while to deploy to your function app but once complete, you should see a green success message in the cloud shell terminal and a new **HTTPExample** function listed in the **Functions** section of the **Overview** blade. | |
|  | |
| - If you click on the **HTTPExample** Function, this will take you to the **Code + Test** console where you can inspect the **function_app.py** Python Code. As you can see below, the template HTTP Trigger code is very simple. It defines a single route which prints a successful message and a personalised message if a **name** is passed as a query parameter. Let's test that next with an API. | |
| - The function will take a while to deploy to your function app but once complete, you should see a green success message in the cloud shell terminal and a new **HttpExample** function listed in the **Functions** section of the **Overview** blade. | |
|  | |
| - If you click on the **HttpExample** Function, this will take you to the **Code + Test** console where you can inspect the **function_app.py** Python Code. As you can see below, the template HTTP Trigger code is very simple. It defines a single route which prints a successful message and a personalised message if a **name** is passed as a query parameter. Let's test that next with an API. |
Copilot
AI
Feb 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On line 78, there's a typo in "HTTExample". It should be "HTTPExample" (with two 'P's) to match the function name used throughout the rest of the document.
| - Validate the function works in the APIM portal. Select the **APIMAZF** API, select **Test**, then select the **HTTExample** post route. Add a **Query Parameter** called **Name** with the value of your choice. Click **Send** to see the response. You can optionally test again but this time remove the **name** query parameter to see a different response. | |
| - Validate the function works in the APIM portal. Select the **APIMAZF** API, select **Test**, then select the **HTTPExample** post route. Add a **Query Parameter** called **Name** with the value of your choice. Click **Send** to see the response. You can optionally test again but this time remove the **name** query parameter to see a different response. |
Copilot
AI
Feb 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On line 96, the list item formatting appears inconsistent. Lines 97-98 are indented sub-items under the instruction on line 96, but they should have proper spacing (two spaces) for markdown list indentation to render correctly. Ensure these items are properly indented as sub-bullets.
| - **Name**: `APIMLGA` | |
| - **Resource Group (re-use Azure Function RG)**: `af-dev-we-apimazf-[your-initials]-01` | |
| - **Name**: `APIMLGA` | |
| - **Resource Group (re-use Azure Function RG)**: `af-dev-we-apimazf-[your-initials]-01` |
Copilot
AI
Apr 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The query parameter name is inconsistent (Name vs name). The generated Azure Functions template typically expects name (lowercase), and the Logic App expression also reads queries['name']. Please use one casing consistently (preferably name) in all steps and screenshots.
Copilot
AI
Feb 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On line 105, the instruction text says "In the HTTP details" but this refers to the HTTP action configuration. For consistency with the rest of the document where UI elements and sections are in bold (e.g., "Basics properties screen" on line 24), this should be "In the HTTP details" or "In the HTTP action details".
| - Click on the **+** to add a **HTTP** action within the **built-in HTTP section**. In the *HTTP* details, enter the following and hit **Save** when complete: | |
| - Click on the **+** to add a **HTTP** action within the **built-in HTTP section**. In the **HTTP** details, enter the following and hit **Save** when complete: |
Copilot
AI
Feb 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On line 104, the instruction refers to "HTTP" with asterisks on both sides, which would render as italics in markdown. This appears to be unintentional - it should likely be "HTTP" (bold) to match the formatting style of other UI element names in the document, or just "HTTP" without any formatting.
| - Click on the **+** to add a **HTTP** action within the **built-in HTTP section**. In the *HTTP* details, enter the following and hit **Save** when complete: | |
| - Click on the **+** to add a **HTTP** action within the **built-in HTTP section**. In the **HTTP** details, enter the following and hit **Save** when complete: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The instruction on line 29 says "Runtime stack: 3.12" but does not specify that this is Python. It should say "Runtime stack: Python 3.12" or similar to be clear, as Azure Functions supports multiple runtimes (Node.js, .NET, Java, etc.).