This Azure Function App is designed to generate JSON Web Tokens (JWT) for authentication purposes in a Qlik Cloud environment. The function is triggered via an HTTP request and generates a JWT using a private key and other environment-specific configurations. This documentation provides a detailed overview of the code and how to set up and deploy the Azure Function App to generate JWT tokens for authentication in Qlik Cloud.
The original script is from this Qlik Dev documentation which uses AWS Lambda. In this guide, we convert the implementation into an Azure Function App.
- Go to Azure Portal
- Select Consumption for the hosting plan.
- Enter your Subscription and Resource Group. Create a new one if you don’t have any.
Configuration:
- Function App name:
azure-qlikcloud-generate-jwt-token
(choose a different name if not available) - Runtime stack: Python
- Version: 3.11
- Region: Choose your region
- Click Review + Create, then click Create to finalize.
-
Navigate to the Azure portal.
-
Locate and select your Azure Function App (
azure-qlikcloud-generate-jwt-token
in this case). -
In the Function App, go to Configuration under the Settings section.
-
Add the following environment variables:
- AzureWebJobsStorage: Obtain the connection string from your Azure Storage account.
Usually, Azure creates this parameter automatically by default when you create a function. Please ignore if this step if the parameter is already present
- On Azure Portal, open the storage account you want to obtain the connection string for. Select Access keys under the Security + networking section.
- You will see two access keys (Key1 and Key2) and the corresponding connection strings for your storage account. Please use any connection string field associated with either Key1 or Key2.
- issuer
- kid
- private_key
For guidance on obtaining the values for
issuer
,kid
, andprivate_key
, refer to Configure JWT IdP. - AzureWebJobsStorage: Obtain the connection string from your Azure Storage account.
We will deploy the functions to the cloud using Azure Functions Core Tools CLI. Azure CLI will handle authentication during this process.
Download and Install these tools:
- Download the package and unzip it.
- Open CMD and navigate to the folder. Use the command:
cd path_to_unzipped_folder/azure-qlikcloud-generate-jwt-token
- Execute the following command to log in:
az login
- Follow the instructions in the terminal to authenticate and complete the login process.
- Execute the following command to publish your Azure Function App to Azure:
func azure functionapp publish azure-qlikcloud-generate-jwt-token --python
- Replace
azure-qlikcloud-generate-jwt-token
with your function name if it's different.
-
In the Azure portal, go to your Function App.
-
Click on the function:
http_trigger_qlikcloud_jwt_token
. -
On the function details page, locate the Get function URL option. Click on it to reveal the URL for invoking your function.
Example:
https://azure-qlikcloud-generate-jwt-token.azurewebsites.net/api/http_trigger_qlikcloud_jwt_token
-
Open the function URL in a web browser. If you receive the expected response, it indicates that the function is properly configured and operational.
{ "body": "eyJhbGciOiJ..." }
- Go to the Embed Iframe Code section of your application.
- In Step 3 - Configure and Embed Iframe Code into the Website, update the
JWTENDPOINT
variable with the Azure Function URL obtained in the previous step.
This completes the setup and deployment of your Azure Function App for generating JWT tokens.