Build a trusted authentication service using Azure Functions

This code sample is meant to be used with Azure Functions, to generate a trusted token provision service. As part of the Azure Communication Services architecture, in order to access communication resources, users or applications require to have an Access Token. It is recommended that the token provisioning logic is held in a trusted and secure service rather than directly on the client as a resource critical information is needed to generated tokens.The Azure Function will work as a trusted middleman between the user and the Communication Services

This quickstart sample includes the code that is explained as part of this document. See that document for additional details on how this sample works.


Running Sample Locally

  1. Ensure to have the Azure Function Extension on Visual Studio. Click into the tab on the left side menu and initialize the project
  2. Open a terminal and navigate to the repository directory
  3. Run cd Trusted Authentication Service to get in the same directory as the function
  4. Run npm i which will install the dependencies for the sample
  5. In Visual Studio Code, click into the index.js file and press F5
  6. Once it runs successfully, on your browser visit: http://localhost:7071/api/Function

Deploy to Azure

To deploy your Azure Function, you can follow step by step instructions

Generally, you will need to:

  1. Sign in to Azure from Visual Studio
  2. Publish your project to your Azure account. Here you will need to choose an existing subscription.
  3. Create a new Azure Function resource using the Visual Studio wizard or use an existing resource. For a new resource, you will need to configure it to your desired region, runtime and unique identifier.
  4. Wait for deployment to finalize
  5. Run the function 🎉

Next steps