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.
- An Azure account with an active subscription. For details, see Create an account for free.
- Visual Studio Code on one of the supported platforms.
- Node.js, Active LTS and Maintenance LTS versions (10.14.1 recommended). Use the
node --versioncommand to check your version.
- The Azure Functions extension for Visual Studio Code.
- An active Communication Services resource and connection string. Create a Communication Services resource.
Running Sample Locally
- Ensure to have the Azure Function Extension on Visual Studio. Click into the tab on the left side menu and initialize the project
- Open a terminal and navigate to the repository directory
cd Trusted Authentication Serviceto get in the same directory as the function
npm iwhich will install the dependencies for the sample
- In Visual Studio Code, click into the
index.jsfile and press
- Once it runs successfully, on your browser visit:
Deploy to Azure
To deploy your Azure Function, you can follow step by step instructions
Generally, you will need to:
- Sign in to Azure from Visual Studio
- Publish your project to your Azure account. Here you will need to choose an existing subscription.
- 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.
- Wait for deployment to finalize
- Run the function 🎉