You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-functions/functions-deployment-slots.md
+83-25Lines changed: 83 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,25 +6,25 @@ ms.date: 03/02/2022
6
6
---
7
7
# Azure Functions deployment slots
8
8
9
-
Azure Functions deployment slots allow your function app to run different instances called "slots". Slots are different environments exposed via a publicly available endpoint. One app instance is always mapped to the production slot, and you can swap instances assigned to a slot on demand. Function apps running under the Apps Service plan may have multiple slots, while under the Consumption plan only one slot is allowed.
9
+
Azure Functions deployment slots allow your function app to run different instances called _slots_. Slots are different environments exposed via a publicly available endpoint. One app instance is always mapped to the production slot, and you can swap instances assigned to a slot on demand. Function apps running in a [Consumption plan](./consumption-plan.md)have a single extra slot for staging. You can obtain more staging slots by running your app in a [Premium plan](./functions-premium-plan.md) or [Dedicated (App Service) plan](./dedicated-plan.md). For more information, see [Service limits](./functions-scale.md#service-limits).
10
10
11
11
The following reflect how functions are affected by swapping slots:
12
12
13
-
- Traffic redirection is seamless; no requests are dropped because of a swap. This seamless behavior is a result of the next function triggers being routed to the swapped slot.
14
-
- Currently executing function are terminated during the swap. Please review [Improve the performance and reliability of Azure Functions](performance-reliability.md#write-functions-to-be-stateless) to learn how to write stateless and defensive functions.
13
+
- Traffic redirection is seamless; no requests are dropped because of a swap. This seamless behavior occurs because the next function trigger is routed to the swapped slot.
14
+
- Currently executing function are terminated during the swap. To learn how to write stateless and defensive functions, see [Improve the performance and reliability of Azure Functions](performance-reliability.md#write-functions-to-be-stateless).
15
15
16
16
## Why use slots?
17
17
18
-
There are a number of advantages to using deployment slots. The following scenarios describe common uses for slots:
18
+
There are many advantages to using deployment slots, including:
19
19
20
20
-**Different environments for different purposes**: Using different slots gives you the opportunity to differentiate app instances before swapping to production or a staging slot.
21
21
-**Prewarming**: Deploying to a slot instead of directly to production allows the app to warm up before going live. Additionally, using slots reduces latency for HTTP-triggered workloads. Instances are warmed up before deployment, which reduces the cold start for newly deployed functions.
22
22
-**Easy fallbacks**: After a swap with production, the slot with a previously staged app now has the previous production app. If the changes swapped into the production slot aren't as you expect, you can immediately reverse the swap to get your "last known good instance" back.
23
-
-**Minimize restarts**: Changing app settings in a production slot requires a restart of the running app. You can instead change settings in a staging slot and swap the settings change into production with a prewarmed instance. This is the recommended way to upgrade between Functions runtime versions while maintaining the highest availability. To learn more, see [Minimum downtime upgrade](migrate-version-3-version-4.md#minimum-downtime-upgrade).
23
+
-**Minimize restarts**: Changing app settings in a production slot requires a restart of the running app. You can instead change settings in a staging slot and swap the settings change into production with a prewarmed instance. Slots are the recommended way to upgrade between Functions runtime versions while maintaining the highest availability. To learn more, see [Minimum downtime upgrade](migrate-version-3-version-4.md#minimum-downtime-upgrade).
24
24
25
25
## Swap operations
26
26
27
-
During a swap, one slot is considered the source and the other the target. The source slot has the instance of the application that is applied to the target slot. The following steps ensure the target slot doesn't experience downtime during a swap:
27
+
During a swap, one slot is considered the source and the other is the target. The source slot has the instance of the application that is applied to the target slot. The following steps ensure the target slot doesn't experience downtime during a swap:
28
28
29
29
1.**Apply settings:** Settings from the target slot are applied to all instances of the source slot. For example, the production settings are applied to the staging instance. The applied settings include the following categories:
30
30
-[Slot-specific](#manage-settings) app settings and connection strings (if applicable)
@@ -33,9 +33,9 @@ During a swap, one slot is considered the source and the other the target. The s
33
33
34
34
1.**Wait for restarts and availability:** The swap waits for every instance in the source slot to complete its restart and to be available for requests. If any instance fails to restart, the swap operation reverts all changes to the source slot and stops the operation.
35
35
36
-
1.**Update routing:** If all instances on the source slot are warmed up successfully, the two slots complete the swap by switching routing rules. After this step, the target slot (for example, the production slot) has the app that's previously warmed up in the source slot.
36
+
1.**Update routing:** If all instances on the source slot are warmed up successfully, the two slots complete the swap by switching routing rules. After this step, the target slot (for example, the production slot) has the app that was previously warmed up in the source slot.
37
37
38
-
1.**Repeat operation:** Now that the source slot has the pre-swap app previously in the target slot, complete the same operation by applying all settings and restarting the instances for the source slot.
38
+
1.**Repeat operation:** Now that the source slot has the preswap app previously in the target slot, complete the same operation by applying all settings and restarting the instances for the source slot.
39
39
40
40
Keep in mind the following points:
41
41
@@ -53,7 +53,7 @@ Some configuration settings are slot-specific. The following lists detail which
53
53
54
54
- Publishing endpoints
55
55
- Custom domain names
56
-
-Non-public certificates and TLS/SSL settings
56
+
-Nonpublic certificates and TLS/SSL settings
57
57
- Scale settings
58
58
- IP restrictions
59
59
- Always On
@@ -73,15 +73,15 @@ Some configuration settings are slot-specific. The following lists detail which
73
73
- Service endpoints *
74
74
- Azure Content Delivery Network *
75
75
76
-
Features marked with an asterisk (*) are planned to be unswapped.
76
+
Features marked with an asterisk (*) don't get swapped, by design.
77
77
78
78
> [!NOTE]
79
79
> Certain app settings that apply to unswapped settings are also not swapped. For example, since diagnostic settings are not swapped, related app settings like `WEBSITE_HTTPLOGGING_RETENTION_DAYS` and `DIAGNOSTICS_AZUREBLOBRETENTIONDAYS` are also not swapped, even if they don't show up as slot settings.
80
80
>
81
81
82
82
### Create a deployment setting
83
83
84
-
You can mark settings as a deployment setting, which makes it "sticky". A sticky setting doesn't swap with the app instance.
84
+
You can mark settings as a deployment setting, which makes it _sticky_. A sticky setting doesn't swap with the app instance.
85
85
86
86
If you create a deployment setting in one slot, make sure to create the same setting with a unique value in any other slot that is involved in a swap. This way, while a setting's value doesn't change, the setting names remain consistent among slots. This name consistency ensures your code doesn't try to access a setting that is defined in one slot but not another.
87
87
@@ -114,9 +114,35 @@ All slots scale to the same number of workers as the production slot.
114
114
- For Consumption plans, the slot scales as the function app scales.
115
115
- For App Service plans, the app scales to a fixed number of workers. Slots run on the same number of workers as the app plan.
116
116
117
+
## View slots
118
+
119
+
You can view information about existing slots using either the [Azure CLI](/cli/azure) or through the [Azure portal](https://portal.azure.com).
120
+
121
+
### [Azure portal](#tab/azure-portal)
122
+
123
+
Use these steps to create a new slot in the portal:
124
+
125
+
1. Navigate to your function app.
126
+
127
+
1. Select **Deployment slots** and the existing slots are shown.
128
+
129
+
### [Azure CLI](#tab/azure-cli)
130
+
131
+
Run this [az functionapp deployment slot list](/cli/azure/functionapp/deployment/slot#az-functionapp-deployment-slot-list) command to list the existing slots in your function app:
132
+
133
+
```azurecli
134
+
az functionapp deployment slot list --name "<APP_NAME>" --resource-group "<RESOURCE_GROUP>"
135
+
```
136
+
137
+
---
138
+
117
139
## Add a slot
118
140
119
-
You can add a slot via the [CLI](/cli/azure/functionapp/deployment/slot#az-functionapp-deployment-slot-create) or through the portal. The following steps demonstrate how to create a new slot in the portal:
141
+
You can add a slot using either the [Azure CLI](/cli/azure) or through the [Azure portal](https://portal.azure.com).
142
+
143
+
### [Azure portal](#tab/azure-portal)
144
+
145
+
Use these steps to create a slot in the portal:
120
146
121
147
1. Navigate to your function app.
122
148
@@ -128,11 +154,30 @@ You can add a slot via the [CLI](/cli/azure/functionapp/deployment/slot#az-funct
128
154
129
155
:::image type="content" source="./media/functions-deployment-slots/functions-deployment-slots-add-name.png" alt-text="Name the Azure Functions deployment slot." border="true":::
130
156
157
+
### [Azure CLI](#tab/azure-cli)
158
+
159
+
Run the [az functionapp deployment slot create](/cli/azure/functionapp/deployment/slot#az-functionapp-deployment-slot-create) command to create a slot named `staging` in your function app:
You access resources (HTTP triggers and administrator endpoints) in a staging slot in the same way as the production slot. However, instead of the function app host name you use the slot-specific host name in the request URL, along with any slot-specific keys. Because staging slots are live apps, you must [secure your functions](./security-concepts.md) in a staging slot as you would in the production slot.
170
+
131
171
## Swap slots
132
172
133
-
You can swap slots via the [CLI](/cli/azure/functionapp/deployment/slot#az-functionapp-deployment-slot-swap) or through the portal. The following steps demonstrate how to swap slots in the portal:
173
+
You can swap slots in an out of production using either the [Azure CLI](/cli/azure) or through the [Azure portal](https://portal.azure.com).
174
+
175
+
### [Azure portal](#tab/azure-portal)
176
+
177
+
Use these steps to swap a staging slot into production:
134
178
135
179
1. Navigate to the function app.
180
+
136
181
1. Select **Deployment slots**, and then select **Swap**.
137
182
138
183
:::image type="content" source="./media/functions-deployment-slots/functions-swap-deployment-slot.png" alt-text="Screenshot that shows the 'Deployment slot' page with the 'Add Slot' action selected." border="true":::
@@ -141,15 +186,28 @@ You can swap slots via the [CLI](/cli/azure/functionapp/deployment/slot#az-funct
141
186
142
187
:::image type="content" source="./media/functions-deployment-slots/azure-functions-deployment-slots-swap-config.png" alt-text="Swap the deployment slot." border="true":::
143
188
144
-
The operation may take a moment while the swap operation is executing.
189
+
The swap operation can take a few seconds.
190
+
191
+
### [Azure CLI](#tab/azure-cli)
192
+
193
+
Run this [az functionapp deployment slot swap](/cli/azure/functionapp/deployment/slot#az-functionapp-deployment-slot-swap) command to swap between a slot named `staging` and the production slot in your function app:
194
+
195
+
```azurecli
196
+
az functionapp deployment slot swap --name "<APP_NAME>" --resource-group "<RESOURCE_GROUP>" --slot staging --target-slot production
197
+
```
198
+
---
145
199
146
200
## Roll back a swap
147
201
148
-
If a swap results in an error or you simply want to "undo" a swap, you can roll back to the initial state. To return to the pre-swapped state, do another swap to reverse the swap.
202
+
If a swap results in an error or you simply want to "undo" a swap, you can roll back to the initial state. To return to the preswapped state, do another swap to reverse the swap.
149
203
150
204
## Remove a slot
151
205
152
-
You can remove a slot via the [CLI](/cli/azure/functionapp/deployment/slot#az-functionapp-deployment-slot-delete) or through the portal. The following steps demonstrate how to remove a slot in the portal:
206
+
You can remove a slot using either the [Azure CLI](/cli/azure) or through the [Azure portal](https://portal.azure.com).
207
+
208
+
### [Azure portal](#tab/azure-portal)
209
+
210
+
Use these steps to remove a slot from your app in the portal:
153
211
154
212
1. Navigate to **Deployment slots** in the function app, and then select the slot name.
155
213
@@ -163,19 +221,19 @@ You can remove a slot via the [CLI](/cli/azure/functionapp/deployment/slot#az-fu
163
221
164
222
:::image type="content" source="./media/functions-deployment-slots/functions-delete-deployment-slot-details.png" alt-text="Delete the deployment slot in the Azure portal." border="true":::
Run the [az functionapp deployment slot delete](/cli/azure/functionapp/deployment/slot#az-functionapp-deployment-slot-delete) command to remove a slot named `staging` from your function app:
171
231
172
-
Using the [Azure CLI](/cli/azure/functionapp/deployment/slot), you can automate the following actions for a slot:
@@ -202,7 +260,7 @@ Use the following steps to change a slot's App Service plan:
202
260
203
261
Azure Functions deployment slots have the following considerations:
204
262
205
-
- The number of slots available to an app depends on the plan. The Consumption plan is only allowed one deployment slot. Additional slots are available for apps running under other plans. For details, see [Service limits](functions-scale.md#service-limits).
263
+
- The number of slots available to an app depends on the plan. The Consumption plan is only allowed one deployment slot. More slots are available for apps running under other plans. For details, see [Service limits](functions-scale.md#service-limits).
206
264
- Swapping a slot resets keys for apps that have an `AzureWebJobsSecretStorageType` app setting equal to `files`.
207
265
- When slots are enabled, your function app is set to read-only mode in the portal.
208
266
- Use function app names shorter than 32 characters. Names longer than 32 characters are at risk of causing [host ID collisions](storage-considerations.md#host-id-considerations).
0 commit comments