|
1 |
| -# serverless-azure-functions |
2 |
| -WIP – Coming soon... |
| 1 | +# Azure Functions Plugin |
| 2 | + |
| 3 | +This plugin enables Azure Functions support within the Serverless Framework. |
| 4 | + |
| 5 | +## Getting started |
| 6 | + |
| 7 | + |
| 8 | +### Get a Serverless Service with Azure as the Provider |
| 9 | + |
| 10 | +1. Clone gitrepo: `git clone -b dev https://github.com/pragnagopa/boilerplate-azurefunctions.git`. |
| 11 | +2. npm install |
| 12 | + |
| 13 | +### Get an Azure Subscription |
| 14 | + - <a href="https://azure.microsoft.com/en-us/free/?b=17.01" target="_blank">Create your free Azure account today</a> |
| 15 | + |
| 16 | +### Create Service Principal User for your Azure subscription |
| 17 | +1. Create a Service Principal User with <a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal" target="_blank">portal</a> or <a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-authenticate-service-principal-cli" target="_blank">Azure CLI</a> |
| 18 | +2. <a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal#get-tenant-id" target="_blank">Get tenant ID</a> |
| 19 | +3. <a href="https://blogs.msdn.microsoft.com/mschray/2015/05/13/getting-your-azure-guid-subscription-id/" target="_blank">Get Azure subscription ID</a> |
| 20 | +4. <a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal#get-application-id-and-authentication-key" target="_blank">Get application ID</a>. Note this is also referred to as the client id. |
| 21 | + |
| 22 | + |
| 23 | +### Set the following environment variables: |
| 24 | + |
| 25 | +- azureSubId: YourAzureSubscriptionID |
| 26 | +- azureServicePrincipalTenantId: servicePrincipalTenantId |
| 27 | +- azureservicePrincipalClientId: servicePrincipalClientId |
| 28 | +- azureServicePrincipalPassword: servicePrincipalPassword |
| 29 | + |
| 30 | +**Note:** If you created Service Principal User from Portal, servicePrincipalPassword is the authentication key |
| 31 | + |
| 32 | +### Update the config in `serverless.yml` |
| 33 | + |
| 34 | +Open up your `serverless.yml` file and update the following information: |
| 35 | + |
| 36 | +#### `service` property |
| 37 | + |
| 38 | +```yml |
| 39 | +service: my-azure-functions-app # Name of the Azure function App you want to create |
| 40 | +``` |
| 41 | +### Quick Start |
| 42 | +
|
| 43 | +1. **Deploy a Service:** |
| 44 | +
|
| 45 | + Use this when you have made changes to your Functions or you simply want to deploy all changes within your Service at the same time. |
| 46 | + ```bash |
| 47 | + serverless deploy |
| 48 | + ``` |
| 49 | + |
| 50 | +2. **Deploy the Function:** |
| 51 | + |
| 52 | + Use this to quickly upload and overwrite your Azure function, allowing you to develop faster. |
| 53 | + ```bash |
| 54 | + serverless deploy function -f httpjs |
| 55 | + ``` |
| 56 | + |
| 57 | +3. **Invoke the Function:** |
| 58 | + |
| 59 | + Invokes an Azure Function on Azure |
| 60 | + ```bash |
| 61 | + serverless invoke --path httpQueryString.json -f httpjs |
| 62 | + ``` |
| 63 | + |
| 64 | +4. **Stream the Function Logs:** |
| 65 | + |
| 66 | + Open up a separate tab in your console and stream all logs for a specific Function using this command. |
| 67 | + ```bash |
| 68 | + serverless logs -f httpjs -t |
| 69 | + ``` |
| 70 | + |
| 71 | +5. **Remove the Service:** |
| 72 | + |
| 73 | + Removes all Functions and Resources from your Azure subscription. |
| 74 | + ```bash |
| 75 | + serverless remove |
0 commit comments