|
| 1 | +# Serverless Configuration |
| 2 | + |
| 3 | +This document serves as a basic outline for configuring your Azure Function App through `serverless.yml`. |
| 4 | + |
| 5 | +- `service` - Name of service. Used to generate name for resource group, function app, and other resources |
| 6 | + |
| 7 | +## Provider Configuration |
| 8 | + |
| 9 | +- `provider.name` - Name of serverless provider. Always `azure` |
| 10 | +- `provider.os` - Operating system for function app. Available options: |
| 11 | + - `windows` (default) |
| 12 | + - `linux` |
| 13 | +- `provider.runtime` - Runtime language for function app. Available options (no default, must be specified): |
| 14 | + - `nodejs10` |
| 15 | + - `nodejs12` |
| 16 | + - `python3.6` (forced to use `linux`) |
| 17 | + - `python3.7` (forced to use `linux`) |
| 18 | + - `python3.8` (forced to use `linux`) |
| 19 | +- `provider.region` - [Azure region](https://azure.microsoft.com/en-us/global-infrastructure/regions/) for resources |
| 20 | +- `provider.prefix` - Prefix used in naming convention for resources. Default `sls` |
| 21 | +- `provider.subscriptionId` - Subscription ID to be used in deployment. Can also be set via: |
| 22 | + - Command-line argument (`--subscriptionId {SUB_ID}`) |
| 23 | + - Environment variable (`AZURE_SUBSCRIPTION_ID`) |
| 24 | +- `provider.stage` - Stage for resources. Default `dev` |
| 25 | + <!-- TODO - provider.type --> |
| 26 | +- `provider.environment` - Key value pairs to set as app settings (environment variables) within function app. Example: |
| 27 | + ```yaml |
| 28 | + provider: |
| 29 | + environment: |
| 30 | + VARIABLE_FOO: 'bar' |
| 31 | + ``` |
| 32 | +- `provider.apim` - APIM Configuration. See [documentation](../docs/examples/apim.md) for more details |
| 33 | + |
| 34 | +## Plugin Configuration |
| 35 | + |
| 36 | +- `plugins` - List of plugins used by service. Must always include: |
| 37 | + `- serverless-azure-functions` |
| 38 | + |
| 39 | +## Package Configuration |
| 40 | + |
| 41 | +- `package.include` - Files or folders to include in package |
| 42 | +- `package.exclude` - Files or folders to exclude from package |
| 43 | + |
| 44 | +## Functions Configuration |
| 45 | + |
| 46 | +Example: |
| 47 | + |
| 48 | +```yaml |
| 49 | +functions: |
| 50 | + hello: |
| 51 | + # Handler is in src/handlers/hello.js and function sayHello |
| 52 | + handler: src/handlers/hello.sayHello |
| 53 | + events: |
| 54 | + # Http Triggered function |
| 55 | + - http: true |
| 56 | + x-azure-settings: |
| 57 | + # Allows GET method |
| 58 | + methods: |
| 59 | + - GET |
| 60 | + authLevel: anonymous # can also be `function` or `admin` |
| 61 | +``` |
| 62 | + |
| 63 | +## Full Example Config |
| 64 | + |
| 65 | +```yaml |
| 66 | +# Welcome to Serverless! |
| 67 | +# |
| 68 | +# This file is the main config file for your service. |
| 69 | +# It's very minimal at this point and uses default values. |
| 70 | +# You can always add more config options for more control. |
| 71 | +# We've included some commented out config examples here. |
| 72 | +# Just uncomment any of them to get that config option. |
| 73 | +# |
| 74 | +# For full config options, check the docs: |
| 75 | +# docs.serverless.com |
| 76 | +# |
| 77 | +# Happy Coding! |
| 78 | + |
| 79 | +service: my-api |
| 80 | + |
| 81 | +# You can pin your service to only deploy with a specific Serverless version |
| 82 | +# Check out our docs for more details |
| 83 | +# frameworkVersion: "=X.X.X" |
| 84 | + |
| 85 | +provider: |
| 86 | + name: azure |
| 87 | + region: West Europe |
| 88 | + runtime: nodejs10.x |
| 89 | + prefix: "sample" # prefix of generated resource name |
| 90 | + # subscriptionId: A356AC8C-E310-44F4-BF85-C7F29044AF99 |
| 91 | + # stage: dev |
| 92 | + # type: premium # premium azure functions |
| 93 | + |
| 94 | + environment: # these will be created as application settings |
| 95 | + VARIABLE_FOO: 'foo' |
| 96 | + |
| 97 | + # you can define apim configuration here |
| 98 | + # apim: |
| 99 | + # apis: |
| 100 | + # - name: v1 |
| 101 | + # subscriptionRequired: false # if true must provide an api key |
| 102 | + # displayName: v1 |
| 103 | + # description: V1 sample app APIs |
| 104 | + # protocols: |
| 105 | + # - https |
| 106 | + # path: v1 |
| 107 | + # tags: |
| 108 | + # - tag1 |
| 109 | + # - tag2 |
| 110 | + # authorization: none |
| 111 | + # cors: |
| 112 | + # allowCredentials: false |
| 113 | + # allowedOrigins: |
| 114 | + # - "*" |
| 115 | + # allowedMethods: |
| 116 | + # - GET |
| 117 | + # - POST |
| 118 | + # - PUT |
| 119 | + # - DELETE |
| 120 | + # - PATCH |
| 121 | + # allowedHeaders: |
| 122 | + # - "*" |
| 123 | + # exposeHeaders: |
| 124 | + # - "*" |
| 125 | + |
| 126 | +plugins: # look for additional plugins in the community plugins repo: https://github.com/serverless/plugins |
| 127 | + - serverless-azure-functions |
| 128 | + |
| 129 | +# you can add packaging information here |
| 130 | +package: |
| 131 | + # include: |
| 132 | + # - include-me.js |
| 133 | + # - include-me-dir/** |
| 134 | + exclude: |
| 135 | + # - exclude-me.js |
| 136 | + # - exclude-me-dir/** |
| 137 | + - local.settings.json |
| 138 | + - .vscode/** |
| 139 | + |
| 140 | +functions: |
| 141 | + hello: |
| 142 | + handler: src/handlers/hello.sayHello |
| 143 | + events: |
| 144 | + - http: true |
| 145 | + x-azure-settings: |
| 146 | + methods: |
| 147 | + - GET |
| 148 | + authLevel: anonymous # can also be `function` or `admin` |
| 149 | + |
| 150 | + goodbye: |
| 151 | + handler: src/handlers/goodbye.sayGoodbye |
| 152 | + events: |
| 153 | + - http: true |
| 154 | + x-azure-settings: |
| 155 | + methods: |
| 156 | + - GET |
| 157 | + authLevel: anonymous |
| 158 | + # The following are a few examples of other events you can configure: |
| 159 | + # storageBlob: |
| 160 | + # handler: src/handlers/storageBlob.printMessage |
| 161 | + # events: |
| 162 | + # - blob: |
| 163 | + # x-azure-settings: |
| 164 | + # name: blob # Specifies which name is available on `context` |
| 165 | + # path: blob-sample/{blobName} |
| 166 | + # connection: AzureWebJobsStorage # App Setting/environment variable which contains Storage Account Connection String |
| 167 | + # storageQueue: |
| 168 | + # handler: src/handlers/storageQueue.printMessage |
| 169 | + # events: |
| 170 | + # - queue: queue-sample |
| 171 | + # x-azure-settings: |
| 172 | + # name: message # Specifies which naem is available on `context` |
| 173 | + # connection: AzureWebJobsStorage |
| 174 | + # timer: |
| 175 | + # handler: src/handlers/timer.printMessage |
| 176 | + # events: |
| 177 | + # - timer: |
| 178 | + # x-azure-settings: |
| 179 | + # schedule: '*/10 * * * * *' |
| 180 | + # eventhub: |
| 181 | + # handler: src/handlers/eventHub.printMessage |
| 182 | + # events: |
| 183 | + # - eventHub: |
| 184 | + # x-azure-settings: |
| 185 | + # name: eventHubMessages # Specifies which name it's available on `context` |
| 186 | + # eventHubName: sample-hub # Specifies the Name of the Event Hub |
| 187 | + # consumerGroup: $Default # Specifies the consumerGroup to listen with |
| 188 | + # connection: EVENT_HUBS_CONNECTION # App Setting/environment variable which contains Event Hubs Namespace Connection String |
| 189 | + # serviceBusQueue: |
| 190 | + # handler: src/handlers/serviceBusQueue.printMessage |
| 191 | + # events: |
| 192 | + # - serviceBus: |
| 193 | + # x-azure-settings: |
| 194 | + # name: message # Specifies which name is available on `context` |
| 195 | + # queueName: sample-queue # Name of the service bus queue to consume |
| 196 | + # connection: SERVICE_BUS_CONNECTION # App Setting/environment variable variable which contains Service Bus Namespace Connection String |
| 197 | + # serviceBusTopic: |
| 198 | + # handler: src/handlers/serviceBusTopic.printMessage |
| 199 | + # events: |
| 200 | + # - serviceBus: |
| 201 | + # x-azure-settings: |
| 202 | + # name: message # Specifies which name it's available on `context` |
| 203 | + # topicName: sample-topic # Name of the service bus topic to consume |
| 204 | + # subscriptionName: sample-subscription # Name of the topic subscription to retrieve from |
| 205 | + # connection: SERVICE_BUS_CONNECTION # App Setting/environment variable variable which contains Service Bus Namespace Connection String |
| 206 | + |
| 207 | +``` |
0 commit comments