How to import an Azure Function App as an API in Azure API Management - Netwoven

How to import an Azure Function App as an API in Azure API Management

By Amitava Das  •  November 25, 2021  •  3294 Views

How to import an Azure Function App as an API in Azure API Management

Introduction:

This document contains importing an Azure Function App as an API into Azure API Management. It defines brief description of Azure Function, Azure API Management,
Observability, API Inspector etc. Main purpose of this document to use Azure API Management to host the Azure Function so that an Anonymous user can’t access that function app easily because it needs some key to access it and Anonymous user have not access of the Azure API Management key.

Azure Function:

Azure Functions is a serverless solution that allows you to write less code, maintain less infrastructure, and save on costs. Instead of worrying about deploying and maintaining servers, the cloud infrastructure provides all the up-to-date resources needed to keep your applications running.

How to import an Azure Function App as an API in Azure API Management

Azure API Management:

Azure API Management is a fully managed service that enables customers to publish, secure, transform, maintain, and monitor APIs. With a few clicks in the Azure portal, you can create an API façade that acts as a “front door” through which external and internal applications can access data or business logic implemented by your custom-built backend services.

There are three components in Azure API management

  1. API Gateway
  2. Developer Portal
  3. Management Plan
How to import an Azure Function App as an API in Azure API Management

Observability

Observability is the ability to understand the internal state of a system from the data it produces and the ability to explore that data to answer questions about what happened and why.

It needs to measure performance of Azure API Management.

APIM instances can be updated or altered using the Management plan which can be accessed from different tools like VS Code extension, Azure portal, PowerShell, ARM templates.

Observability can be achieved by integrating API with Azure Monitor, Azure application insight, and Azure Event Hubs.

The following are the various observability options provided for Azure API.

How to import an Azure Function App as an API in Azure API Management

You may also like: Learn how to proactively identify and protect your sensitive information

API Inspector

API Management provides an API Inspector tool to help you with debugging and troubleshooting your APIs.

API Inspector allows you to troubleshoot your API in Realtime. This feature can be turned on per request with a special header and this allows you to retrieve information like the Request received by the API, what policies have been applied to these requests, duration of each policy execution, and the request sent by the API to the backend and even also the response received.

api-inspector (1.659 ms)
    {
    "request": {
        "method": "GET",
        "url": "https://testfunctionapp123.azure-api.net/testfunctionamitava123/HttpTrigger1",
        "headers": [
            {
                "name": "sec-ch-ua",
                "value": "\"Google Chrome\";v=\"95\",\"Chromium\";v=\"95\",\";Not A Brand\";v=\"99\""
            },
            {
                "name": "sec-ch-ua-mobile",
                "value": "?0"
            },
            {
                "name": "Ocp-Apim-Subscription-Key",
                "value": "aa361cb81cde4618ae178dcdd33932fe"
            },
            {
                "name": "sec-ch-ua-platform",
                "value": "\"Windows\""
            },
            {
                "name": "Sec-Fetch-Site",
                "value": "cross-site"
            },
            {
                "name": "Sec-Fetch-Mode",
                "value": "cors"
            },
            {
                "name": "Sec-Fetch-Dest",
                "value": "empty"
            },
            {
                "name": "X-Forwarded-For",
                "value": "202.142.115.153"
            },
            {
                "name": "Cache-Control",
                "value": "no-cache, no-store"
            },
            {
                "name": "Content-Type",
                "value": "text/plain;charset=UTF-8"
            },
            {
                "name": "Accept",
                "value": "*/*"
            },
            {
                "name": "Accept-Encoding",
                "value": "gzip,deflate,br"
            },
            {
                "name": "Accept-Language",
                "value": "en-US,en;q=0.9"
            },
            {
                "name": "Host",
                "value": "testfunctionapp123.azure-api.net"
            },
            {
                "name": "Referer",
                "value": "https://apimanagement.hosting.portal.azure.net/"
            }
        ]
    }
}
________________________________________
api-inspector (0.059 ms)
    {
    "configuration": {
        "api": {
            "from": "/testfunctionamitava123",
            "to": null,
            "version": null,
            "revision": "1"
        },
        "operation": {
            "method": "GET",
            "uriTemplate": "/HttpTrigger1"
        },
        "user": "-",
        "product": "-"
    }
}
________________________________________
cors (0.109 ms)
    "Origin header was missing or empty and the request was classified as not cross-domain. CORS policy was not applied."
________________________________________
set-backend-service (0.020 ms)
    "Backend 'testfunctionamitava123' set to current."

The next section consists of this different things:

We are going to import Azure Function as an API into Azure API Management and test the API in Azure portal.

  • Import an Azure Function App as an API
  • View the new Azure Function App host key and Azure API Management named value
  • Test the API in the Azure portal

Import an Azure Function App as an API

Go to your API Management instance

  • In the Azure portal, search for and select API Management services.
How to import an Azure Function App as an API in Azure API Management
  • On the API Management services page, select your API Management instance.
How to import an Azure Function App as an API in Azure API Management

Import an Azure Function App as a new API

Follow the steps below to create a new API from an Azure Function App.

  • Navigate to your API Management service in the Azure portal and select APIs from the menu.
  • In the Add a new API list, select Function App.
How to import an Azure Function App as an API in Azure API Management
  • Click Browse to select Functions for import.
How to import an Azure Function App as an API in Azure API Management
  • Click on the Function App section to choose from the list of available Function Apps.
How to import an Azure Function App as an API in Azure API Management
  • Find the Function App you want to import Functions from, click on it and press Select.
How to import an Azure Function App as an API in Azure API Management
  • Select the Functions you would like to import and click Select.
    • You can only import Functions based off HTTP trigger with Anonymous or Function authorization levels.
How to import an Azure Function App as an API in Azure API Management
How to import an Azure Function App as an API in Azure API Management

Test the Azure Function

How to import an Azure Function App as an API in Azure API Management
HTTP/1.1 200 OK
content-encoding: gzip
content-type: text/plain; charset=utf-8
date: Fri, 12 Nov 2021 14:51:47 GMT
ocp-apim-apiid: testfunctionamitava123
ocp-apim-operationid: get-httptrigger1
ocp-apim-subscriptionid: master
ocp-apim-trace-location: https://apimst5xuzgmqovwwadcd1ye.blob.core.windows.net/apiinspectorcontainer/cHcJa9krxa3PhOTGYwgFgw2-4?sv=2019-07-07&sr=b&sig=AyaQH9%2BA%2Fbd3hvaTp6Qtn2THzivcyqHcotrvcHw2uEc%3D&se=2021-11-13T14%3A51%3A47Z&sp=r&traceId=973078ba6b8d48c2b6066dc769e6f42c
request-context: appId=cid-v1:80b93218-47ed-46dd-b579-f6f9f7e02b81
transfer-encoding: chunked
vary: Accept-Encoding,Origin
    This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.

Benefits of Azure API Management:

Save time through centralised access

Before software like Microsoft Azure API Management hit the market, developers would have to manually check through thousands of APIs to monitor their progress and ensure each one was performing at best capacity. Microsoft Azure API Management automates and facilitates the design, deployment, and maintenance of your APIs in one place, saving precious developer time.

Increased API security

Microsoft Azure API Management has a range of security options that add an extra barrier around your sensitive data. These methods include authorisation keys, back-end API security, client certificates, and APIM to back-end API Mutual certification.

Optimizing APIs with full visibility

For larger businesses, the process of manually checking in on APIs is very time-consuming. Thankfully, Azure API Management provides a single gateway for all API monitoring activities. Developers can check in on the progress of their APIs and view automatic reports to help ensure everything is optimised correctly. If there is an issue with an API, it can easily be fixed at an early stage and prevent a “domino effect” with other APIs later on.

Empower third parties with your APIs for free

Microsoft Azure API Management developer portal provides an easy way for third-party developers to understand your APIs and try them out before usage. With either a managed or a self-hosted version of the portal, you have plenty of options to customise and extend the functionality. And the best part? The portal is free to use and automatically generated.

To learn more about Netwoven’s information protection and compliance capabilities, read our datasheet.

Learn how Netwoven’s solution can proactively identify and protect your sensitive data download our Solution Brief.

Conclusion:

APIs are about bringing applications together seamlessly, and Azure API Management platform makes that process fast, cost-effective, and secure. Having the ability to manage and control the entire API ecosystem through one “gateway” is essential for an enterprise to succeed and work effectively.

The Azure API Management platform empowers developers to monitor the performance of APIs quickly and make simple tweaks early on. The software also adds an added level of security for businesses looking to protect valuable data.

Overall, effective API management is a vital part of a modern digital integration strategy. And a platform like Microsoft Azure API Management accelerates and secures the entire API lifecycle, so your business can thrive in the API-led marketplace.

Leave a comment

Your email address will not be published. Required fields are marked *

Dublin Chamber of Commerce
Microsoft Partner
Microsoft Partner
Microsoft Partner
Microsoft Partner
Microsoft Partner
Microsoft Partner
Microsoft Fast Track
Microsoft Partner
Microsoft Fabric
MISA
MISA
Unravel The Complex
Stay Connected

Subscribe and receive the latest insights

Netwoven Inc. - Microsoft Solutions Partner

Get involved by tagging Netwoven experiences using our official hashtag #UnravelTheComplex