Azure / Azure/Azure-Functions

Reusing deleted slot name in function app deployment overwrites production slot as it remembers the previously deleted slot's WEBSITE_CONTENTSHARE

Open
#2,664 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
PowerShell
Stars
1.1k
Forks
215
Avg merge
4h 2m
Merged PRs (30d)
1

Description

I have two quite old function app deployments, perhaps 5+ years old. When I create a staging slot called "staging" the WEBSITE_CONTENTSHARE value from the production slot is copied to the staging slot and the production slot stops working:

- Create staging slot called "staging" using Azure CLI
- Staging slot is created with same WEBSITE_CONTENTSHARE as production slot
- Staging slot is empty, no app published but shows the same functions as the production slot
- Production slot stops working as the staging slot competes for resources such as using the same production slot ASB connection

The production slot is:
```
WEBSITE_CONTENTSHARE = test-3bd8d91e
```
then create the staging slot:
```
az functionapp deployment slot create \
--slot staging \
--resource-group therg \
--name Test
```
and the staging slot is the same as the production slot
```
WEBSITE_CONTENTSHARE = test-3bd8d91e
```
The issue occurs when creating the slot using the portal too.

If I don't call the slot "staging" the process works and the new slot gets a new WEBSITE_CONTENTSHARE and does not have "ghost" functions from the production slot. If I delete the working slot and create a slot called "staging" again the problem appears again.

WEBSITE_CONTENTSHARE is remembered for slot names:
- create slot "preproduction"
- slot gets unique WEBSITE_CONTENTSHARE
- delete slot "preproduction"
- create slot "preproduction"
- slot gets same WEBSITE_CONTENTSHARE it had when it was first created

If the "preproduction" slot is swapped into production, then production will have the WEBSITE_CONTENTSHARE of "preproduction"? If "preproduction" is then deleted and recreated at some point in the future it will have the same WEBSITE_CONTENTSHARE it was assigned the first time it was created. This is the same value as production and explains the "ghost" functions and competition for resources with production.

The behaviour doesn't occur on newer function app deployments, where the slot gets a new WEBSITE_CONTENTSHARE, even if it's called "staging" which suggests this is their first "staging" slot.

I noticed that the production WEBSITE_CONTENTSHARE doesn't have a "-" in a working app and its staging slot does have a "-". In the bad function apps, both production and staging have a "-" in WEBSITE_CONTENTSHARE which suggests they came from a slot swap.

It would appear the only "safe" way to approach a deployment using a slot is to use the date in the slot name, in case that name has been used in the past and swapped into production and then deleted, in which case, reusing that name effectively "tunnels into" the production slot and destroys it until the "ghost" slot is deleted.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.