I'd like to know how I can get a unique identifier for the "slot instance" that an Azure App Service slot has loaded into it.
Note that I am not referring to the name of the slot.
For example:
- My Azure App Service has two slots named "App" (Production) and "App-Staging" (Staging).
- I then deploy version 1 of my project to the "App" slot.
- I then deploy version 2 of my project to the "App-Staging" slot.
I then perform a Slot Swap operation from the Azure Portal:
- Both instances of my app are running simultaneously (imagine they run in a container of some kind).
- Both "containers" are immediately "detached" from their associated slot while still running.
- Both "containers" are then immediately re-attached to the opposing slot.
- i.e. version 1 stops receiving HTTP requests for
app.azurewebsites.net
and suddenly starts receiving requests forapp-staging.azurewebsites.net
. - and version 2 stops receiving HTTP requests for
app-staging.azurewebsites.net
and suddenly starts receiving requests forapp.azurewebsites.net
.
- i.e. version 1 stops receiving HTTP requests for
In order to investigate some issues I was having, I created a text file at
D:\home\SlotName.txt
. In the "App" slot I entered "SlotA" and in the "App-Staging" slot I entered "SlotB".- This
SlotName.txt
moves with the application instance, and allows my application to detect which filesystem or "container" instance it's living in - and this doesn't change when a slot-swap is performed. - I find this information essential when trying to uniquely identify deployments or when investigating logging continuity issues (as the staging slot won't be logging production data, for example).
- However, my
SlotName.txt
file seems like a hack - but I can't see any information in the Environment Variables for my app's instance that reveals the same information.- Environment variables do reveal the slot name, e.g. "App" and "App-Staging" which is mutable - of course, but it doesn't uniquely identify the "container" or filesystem instance that the app is deployed into.
Here's the two Kudu Environment pages from the Production and Staging slots - notice that the values are either identical (like Machine name
), slot-specific, or refer to the deployed application code and none of them refer to the filesystem / container instance they live in:
Is there any way to get this information without using my SlotName.txt
trick?