v6.5.0or later. (this is the runtime version supported by Azure Functions)
v1.9.0or later. You can run
npm install -g serverlessto install it.
npm install -g serverless-azure-functions
Create a new service using the Node.js template, specifying a unique name and an optional path for your service.
$ serverless create --template azure-nodejs --path my-service --name my-unique-name $ cd my-service $ npm install
Deploy your new service to Azure! The first time you do this, you will be asked
to authenticate with your Azure account, so the
serverless CLI can manage
Functions on your behalf. Simply follow the provided instructions, and the
deployment will continue as soon as the authentication process is completed.
Note: Once you've authenticated, a new Azure "service principal" will be created, and used for subsequent deployments. This prevents you from needing to manually login again. See below if you'd prefer to use a custom service principal instead.
Use this to quickly upload and overwrite your function code,allowing you to develop faster. If you're working on a single function, you can simply deploy the specified function instead of the entire service.
serverless deploy function -f hello
Invoke a function, in order to test that it works:
serverless invoke -f hello
Open up a separate tab in your console and stream all logs for a specific Function using this command.
serverless logs -f hello -t
If at any point, you no longer need your service, you can run the following command to remove the Functions, Events and Resources that were created, and ensure that you don't incur any unexpected charges.
Check out the Serverless Framework Guide for more information.
The getting started walkthrough illustrates the interactive login experience, which is recommended for most users. However, if you'd prefer to create an Azure "service principal" yourself, you can indicate that this plugin should use its credentials instead, by setting the following environment variables:
export azureSubId='<subscriptionId>' export azureServicePrincipalTenantId='<tenantId>' export azureServicePrincipalClientId='<servicePrincipalName>' export azureServicePrincipalPassword='<password>'
$env:azureSubId='<subscriptionId>' $env:azureServicePrincipalTenantId='<tenantId>' $env:azureServicePrincipalClientId='<servicePrincipalName>' $env:azureServicePrincipalPassword='<password>'