Getting started¶
To setup Bifravst on Azure, complete the following steps:
Check and make sure that you have the necessary system requirements.
Clone the project and install dependencies.
Install the Azure CLI.
Install the Azure Functions Core Tools.
Deploy the solution to your account.
System requirements¶
You need a development environment with the upcoming LTS release candidate of Node.js (current release is version 14).
If you are using Windows, use the Windows Subsystem for Linux with Ubuntu 18.04 LTS.
Clone the project and install the dependencies¶
Clone the latest version of the Azure project and install the dependencies by running the following commands:
git clone https://github.com/bifravst/azure.git bifravst-azure
cd bifravst-azure
npm ci
npx tsc
Install the Azure CLI¶
Follow the instructions from the Azure CLI documentation to install the CLI.
After installing the CLI, you must be able to execute the az
command:
az
Dockerizing the az
command¶
In case you encounter the issue where the Azure CLI requires an older Python version, you can dockerize it as follows:
#!/usr/bin/env bash
set -eu
command="$@"
docker run --rm --volume `pwd`:/root --volume $HOME/.azure:/root/.azure -w=/root mcr.microsoft.com/azure-cli az $command
Add the command to an executable file in your path.
Install the Azure Functions Core Tools¶
To install the Azure Functions Core Tools, follow the Azure Functions Core Tools installation instructions.
After the installation, you must be able to execute the func
command:
func
Deploy the solution to your account¶
Note
Since the project uses Azure Active Directory B2C, it is recommended to set up Bifravst in a dedicated subscription.
To deploy the solution to your account, complete the following steps:
In the Azure portal, navigate to the Subscriptions blade, and add a new subscription for Bifravst. Export the subscription ID onto the
SUBSCRIPTION_ID
environment variable:export SUBSCRIPTION_ID="<Subscription ID>"
Authenticate the CLI using the following command:
az login
Choose a name for the solution and export it as
APP_NAME
. In this example, we usebifravst
as the default name.Deploy the solution in your preferred location (you can list the locations using
az account list-locations
) and export it on the environment variableLOCATION
.As the recommended workflow, use a direnv) plugin for your shell, which locates the environment variables in a
.envrc
file in the project folder and automatically exports them.Create a new file
.envrc
in the project folder and add the following environment variables:export LOCATION=northeurope
Create the resource group for the solution:
az group create --subscription $SUBSCRIPTION_ID -l $LOCATION -n ${APP_NAME:-bifravst}
Currently, it is not possible to create Active Directory B2C and application through the ARM template (see GitHub issue). You must follow the instructions in the tutorial for registering a web application in Azure Active Directory B2C and create a B2C tenant and an application. Use
http://localhost:3000/
(for local development) andhttps://${APP_NAME:-bifravst}app.z16.web.core.windows.net/
as the redirect URLs.Save the
directory (tenant) id
of the created Active Directory B2C and theapplication (client) id
to the environment variableAPP_REG_CLIENT_ID
in the.envrc
file:export APP_REG_CLIENT_ID=...
Create the user flow for sign up, sign in, and make sure to name the userflow as
B2C_1_signup_signin
.Run the following command to allow the changed file:
direnv allow
Deploy the solution by running the following commands:
az deployment group create --resource-group ${APP_NAME:-bifravst} \ --mode Complete --name ${APP_NAME:-bifravst} \ --template-file azuredeploy.json \ --parameters \ appName=${APP_NAME:-bifravst} \ location=$LOCATION appRegistrationClientId=$APP_REG_CLIENT_ID \ b2cTenant=$B2C_TENANT # Currently it is not possible to enable website hosting through the ARM template az storage blob service-properties update \ --account-name ${APP_NAME:-bifravst}app --static-website --index-document index.html az storage blob service-properties update \ --account-name ${APP_NAME:-bifravst}deviceui \ --static-website --index-document index.html # Deploy the functions func azure functionapp publish ${APP_NAME:-bifravst}API --typescript