Deploy usage guide and design decision.
By default, all functions are deploy to a stage (dev
) and a region. The autogenerated resource group name will reflect this information. The name follow the Microsoft recommended naming convention.
sls deploy -s dev -r westus2 -g myResourceGroup
- Use resource group
myResourceGroup
- Create/Update app service plan, app service
- Zipdeploy code
To apply tags to your resource group, you can specify them in your provider config as such:
...
provider:
tags:
TAG_1: tagValue1
TAG_2: tagValue2
Existing tags with the same names will be updated. Existing tags (with different names) will not be removed.
sls deploy -s dev -r westus2
- Create if not exist resource group
<service>-dev-westus2-rg
- Create/Update app service plan, app service
- Zipdeploy code
- it is not clear if a resourceGroup has already been associated with a given stage and region.
For example, we have the following default config
provider:
stage: dev
region: westus
resourceGroup: myResourceGroup
then user try to deploy
sls deploy -s prod -r westus
- Do we use the environment variables / creds associated with
dev
orprod
? - Someone new to the codecase see both the
serverless.yaml
and the command in a CD script, how can they tell which resourceGroup goes where.
sls deploy -s prod -r westus -g prodResourceGroup
- With this format, it's more clear which stage+region combo is associated with a resourceGroup.
- User can still make mistake, however, and use the
wrong
resource group for a specific stage.
- always using the right resource group
- restrictive for user who have already defined their resources
- can specify storage account for your Azure Functions
- specified storageAccount need to be unique
- default storageAccount is
sls<region><stage><6-char resource group hash>
provider:
stage: dev
region: westus
resourceGroup: myResourceGroup
storageAccount:
name: myStorageAccountName
- Deploy resource group, upload packaged artifact directly to function app. Sets function app
RUN_FROM_PACKAGE
setting to1
.
- Deploy resource group, upload packaged function app to blob storage with version name. Sets function app
RUN_FROM_PACKAGE
setting to path of zipped artifact in blob storage - Default container name -
DEPLOYMENT_ARTIFACTS
(configurable inserverless.yml
, see below)
service: my-app
provider:
deployment:
# Rollback enabled, deploying to blob storage
# Default is true
# If false, deploys directly to function app
rollback: true
# Container in blob storage containing deployed packages
# Default is DEPLOYMENT_ARTIFACTS
container: MY_CONTAINER_NAME
# Sets the WEBSITE_RUN_FROM_PACKAGE setting of function app
# to the SAS url of the artifact sitting in blob storage
# Recommended when using linux, not recommended when using windows
# Default is false
runFromBlobUrl: true
plugins:
- serverless-azure-functions
package:
...
functions:
...
If rollback is enabled, the name of the created package will include the UTC timestamp of its creation. This timestamp will also be included in the name of the Azure deployment so as to be able to link the two together. Both names will have -t{timestamp}
appended to the end.
sls deploy list
- Logs list of deployments to configured resource group with relevant metadata (name, timestamp, etc.). Also logs versions of deployed function app code if available