This guide is designed to help you get started as quick as possible.
To setup the boilerplate, follow these instructions:
Install the boilerplate
serverless create -t azure-nodejs --path <my-app>
Install the dependencies
cd <my-app> npm install
We'll set up an Azure Subscription and our service principal. You can learn more in the credentials doc.
Set up an Azure Subscription
Sign up for a free account @ https://azure.com.
Azure comes with a free trial that includes $200 of free credit.
. Get the Azure CLI
npm i -g azure-cli
Login to Azure
This will give you a code and prompt you to visit aka.ms/devicelogin. Provide the code and then login with your Azure identity (this may happen automatically if you're already logged in). You'll then be able to access your account via the CLI.
Get your subcription and tenant id
azure account show
Save the subcription and tenant id for later
Create a service principal for a given
azure ad sp create -n <name> -p <password>
This should return an object which has the
servicePrincipalNames property on it. Save one of the names in the array and the password you provided for later. If you need to look up your service principal later, you can use
azure ad sp -c <name> where
<name> is the name provided originally. Note that the
<name> you provided is not the name you'll provide later, it is a name in the
Set up environment variables
You need to set up environment variables for your subscription id, tenant id, service principal name, and password.
# bash export azureSubId='<subscriptionId>' export azureServicePrincipalTenantId='<tenantId>' export azureServicePrincipalClientId='<servicePrincipalName>' export azureServicePrincipalPassword='<password>'
# PowerShell $env:azureSubId='<subscriptionId>' $env:azureServicePrincipalTenantId='<tenantId>' $env:azureServicePrincipalClientId='<servicePrincipalName>' $env:azureServicePrincipalPassword='<password>'
Run the deploy command
Run the invoke command
serverless invoke -f hello