Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Commit 620967b

Browse files
committed
docs: Design documents for rollback functionality (#170)
Resolves [AB#325]
1 parent 118b77e commit 620967b

File tree

3 files changed

+139
-75
lines changed

3 files changed

+139
-75
lines changed

docs/DEPLOY.md

+62-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Overview
1+
# Deploy Overview
22

33
Deploy usage guide and design decision.
44

@@ -56,3 +56,64 @@ then user try to deploy
5656

5757
1. always using the right resource group
5858
1. restrictive for user who have already defined their resources
59+
60+
## Deployment Methodologies
61+
62+
#### 1. Deployment to Function App (rollback disabled)
63+
- Deploy resource group, upload packaged artifact directly to function app. Sets function app `RUN_FROM_PACKAGE` setting to `1`.
64+
65+
#### 2. Deployment to Blob Storage (rollback enabled)
66+
- 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
67+
- Default container name - `DEPLOYMENT_ARTIFACTS` (configurable in `serverless.yml`, see below)
68+
69+
### Deployment configuration
70+
71+
```yml
72+
service: my-app
73+
provider:
74+
...
75+
76+
plugins:
77+
- serverless-azure-functions
78+
79+
package:
80+
...
81+
82+
deploy:
83+
# Rollback enabled, deploying to blob storage
84+
# Default is true
85+
# If false, deploys directly to function app
86+
rollback: true
87+
# Container in blob storage containing deployed packages
88+
# Default is DEPLOYMENT_ARTIFACTS
89+
container: MY_CONTAINER_NAME
90+
91+
functions:
92+
...
93+
```
94+
95+
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.
96+
97+
##### Sequence diagram for deployment to blob storage
98+
99+
```mermaid
100+
sequenceDiagram
101+
participant s as Serverless CLI
102+
participant r as Resource Group
103+
participant f as Function App
104+
participant b as Blob Storage
105+
106+
note right of s: `sls deploy`
107+
s ->> r: Create resource group
108+
s ->> r: Deploy ARM template
109+
r ->> f: Included in ARM template
110+
r ->> b: Included in ARM template
111+
note right of s: Zip code
112+
s ->> b: Deploy zip code with name {appName}-v{version}.zip
113+
s ->> f: Set package path in settings
114+
note right of s: Log URLs
115+
```
116+
117+
##### Sub-Commands
118+
119+
- `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

docs/ROLLBACK.md

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Rollback
2+
3+
##### `sls rollback`
4+
- Description - Roll back deployment of Function App & Resource Group
5+
- Options:
6+
- `-t` or `--timestamp` - Timestamp associated with version to target
7+
- Use `sls deploy list` to discover timestamps
8+
- Defaults to previous deployment
9+
- **Important to note that there is no option for rolling back an individual function. A function app is considered one unit and will be rolled back as such.**
10+
- In order to roll back your function app, make sure your `deploy.rollback` is either set to `true` or not specified (defaults to `true`). The container in Azure Blob Storage which contains the packaged code artifacts can also be specified, defaults to `DEPLOYMENT_ARTIFACTS` (see [deploy documentation](./DEPLOY.md))
11+
12+
##### Example usage
13+
14+
```bash
15+
# List all deployments to know the timestamp for rollback
16+
$ sls deploy list
17+
Serverless:
18+
-----------
19+
Name: myFunctionApp-t1561479533
20+
Timestamp: 1561479533
21+
Datetime: 2019-06-25T16:18:53+00:00
22+
-----------
23+
Name: myFunctionApp-t1561479506
24+
Timestamp: 1561479506
25+
Datetime: 2019-06-25T16:18:26+00:00
26+
-----------
27+
Name: myFunctionApp-t1561479444
28+
Timestamp: 1561479444
29+
Datetime: 2019-06-25T16:17:24+00:00
30+
-----------
31+
32+
$ sls rollback -t 1561479506
33+
```
34+
35+
##### Sequence diagram for rollback
36+
37+
```mermaid
38+
sequenceDiagram
39+
participant s as Serverless CLI
40+
participant r as Resource Group
41+
participant f as Function App
42+
participant b as Blob Storage
43+
44+
note right of s: `sls rollback`
45+
s ->> r: Request deployments
46+
r ->> s: Return deployments
47+
note right of s: Select deployment
48+
s ->> r: Deploy ARM template
49+
s ->> b: Request names of previously deployed artifacts
50+
b ->> s: Return names
51+
note right of s: Select artifact
52+
s ->> r: Re-deploy template
53+
s ->> f: Update RUN_FROM_PACKAGE path (could be done with above step)
54+
note right of s: Log URLs
55+
```

0 commit comments

Comments
 (0)