Step 6: Create the Azure Security Policy for the Proxy Service in the Portal¶
The previous steps allow your imported APIs (and Azure Function) to be called by Snowflake, as well as other authenticated clients, such as applications that are in your Azure AD tenant or have a service principal in your Azure AD tenant.
If you want to allow only Snowflake to call the Azure Function, you must implement token validation. With token validation, when Snowflake tries to access the API Management service, Snowflake presents a JWT (JSON Web Token) access token obtained from Azure AD. The API Management service can either validate the JWT or pass it through without validation.
This topic provides instructions for creating a security policy for the API Management service by adding a validate-JWT policy that defines the rules for validating the token.
Snowflake strongly recommends creating a security policy for the API Management service. After completing this step, only Snowflake is allowed to call your Azure Function through the API Management service.
If you prefer to use role-based validation in your validate-JWT policy, see the Microsoft Serivce Principal documentation for assigning a role to a service principal: New-AzureADServiceAppRoleAssignment.
In this Topic:
Create a validate-JWT Policy that Allows Snowflake to Call the Azure Function¶
This section shows how to specify a policy for validating a JSON Web Token (JWT) that authorizes Snowflake to call your Azure Function. The validation policy (“validate-JWT policy”) validates the following two claims in the JWT:
The Snowflake service principal application ID (the “requestor AppID” or just “appid”).
The target application App ID (the “audience ID” or just “aud”) of the Azure Function.
For more information about claims in JSON Web Tokens (JWTs) issued by Azure Active Directory, see the Microsoft documentation: access tokens.
The following steps configure the imported API to use a JSON Web Token:
If you haven’t already, log into the Azure Portal.
Go to the API Management service screen.
Select your API Management service.
Find the APIs section in the left-hand column, then click on the APIs option under that.
In the column that contains All APIs, click on the name of the API for which you want to add a security policy.
Look for In-bound Processing:
Click on + Add policy.
Click on validate-jwt.
Fill in the Header name with the value
Add validation for the JWT (JSON Web Token) provided by Snowflake for accessing the Azure Function:
Look for Required claims and click on + Add claim.
Fill in the Name field with
aud(short for “audience”).
Within the required claim, Look for Values and click on +Add value.
Add the UUID that you copied to the azure_ad_application_id field in the CREATE API INTEGRATION command. This is recorded in the “Azure Function App AD Application ID” field of your tracking worksheet.
Add a separate “claim” for Snowflake:
Click on + Add claim again:
Fill in the Name field with the literal string
Within the claim, click on + Add value and add the Snowflake Application ID in the Values field.
If you do not already have the Snowflake Application ID, you can get it by performing the following steps (the Snowflake Application ID is in the Application ID field):
In the worksheet, find the AZURE_MULTI_TENANT_APP_NAME that you filled in earlier.
In the Azure Portal search box, look for Enterprise Applications.
This takes you to the Enterprise applications | All applications screen.
In that screen, search for the AZURE_MULTI_TENANT_APP_NAME.
The enterprise applications search box does not have a label. Look for a wide field immediately above the list of enterprise applications. The box might say something similar to First 50 shown, to search all of your applications, enter a display name or the application ID.
If you do not find an exact match for the AZURE_MULTI_TENANT_APP_NAME, then search again using only the first several characters of this name (if the name contains an underscore, then do not include the underscore or any characters after the underscore).
Find the Application ID value for the AZURE_MULTI_TENANT_APP_NAME.
Paste the following into Open ID URLs:
<tenant_id>with your Azure AD Tenant ID (as described in the Prerequisites section for planning an external function).
Click on Save.
Test Your External Function¶
To make sure that your external function works correctly with the new security policy, call your external function again.
For details, see Calling an External Function for Azure.
Restrict the IP Addresses That Accept Azure Function Calls (Optional)¶
In addition to specifying a validate-JWT policy (or using role-based validation), you can implement additional security by restricting IP addresses. This ensures that only the API Management service’s IP address is allowed to access the Azure Function app containing your Azure Function.
For more information about restricting IP addresses, see the Microsoft documentation: In-bound IP address restrictions.
None. You’ve successfully created an external function for Azure.