ENV Variables set in deployment slot (staging) is missing in production

Emil Paaske Kvandal 80 Reputation points
2026-05-28T09:21:52.7566667+00:00

We currently have 2 deployment slots, staging and production. We have published our app to staging and set the env variables that needed to be set, though when we choose to swap from staging into production the env variables were not present in our production slot? Also the variables are NOT marked as deployment slot setting.

Which makes me think, if it even swapped the variables?

When we click "swap" and select the staging as the source and production as the target, then we see the following:

Source slot changes

SettingNew valueSetting 1falseSetting 2Not setAnd it basically continues with the "Not set" for the other settings aswell.

Target slot changes

SettingOld valueNew valueSetting 1falsetrueSetting 2Not setNEW VALUEAnd as before, it continues with the Old value being "Not set" and New value being the expected value.

When looking into the logs, i can see that the Operation "Swap Web App Slots" are either succeeded or accepted", which i would take as it should have swapped the settings.

Are we missing something, for this to work?

Azure App Service
Azure App Service

Azure App Service is a service used to create and deploy scalable, mission-critical web apps.


Answer accepted by question author
Golla Venkata Pavani 7,535 Reputation points Microsoft External Staff Moderator
2026-06-01T23:49:47.59+00:00

Hi @Emil Paaske Kvandal ,

Thank you for the clear explanation and for sharing the swap preview details, it really helps.

The behavior you're seeing in the swap preview is expected and actually indicates that the swap is working correctly.

  • Source slot changes (Staging) showing “Not set” means those settings are being moved away from staging.
  • Target slot changes (Production) showing the new values means Production is receiving them from Staging.

Recommended Steps to Resolve This

Here’s what I suggest you do:

  1. Verify the settings in Production after swap Go to your Production slot → Settings > Environment variables and confirm whether the values are now present.
  2. Double-check Deployment slot setting In both Staging and Production slots:
    • Open each environment variable.
    • Ensure Deployment slot setting is unchecked. Even one variable accidentally marked as slot-specific will not swap.
  3. Restart the Production slot After the swap, go to the Production slot > Overview > Click Restart. App Service injects environment variables at startup, so a restart is often required for the app to pick up the new values.
  4. Best Practice for Future Swaps Add the same environment variable keys to both Production and Staging slots (with environment-appropriate values). This makes swaps more reliable and the preview cleaner.

Reference:
https://learn.microsoft.com/en-us/azure/app-service/deploy-staging-slots

Kindly let us know if the above helps or you need further assistance on this issue.

Please "accept" if the information helped you. This will help us and others in the community as well.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

Answer accepted by question author
Jerald Felix 18,760 Reputation points Volunteer Moderator
2026-05-28T17:39:21.34+00:00

Hello Emil Paaske Kvandal,

Greetings! Thanks for raising this question in Q&A forum.

Great observation and a very well-described issue! What you are seeing in the swap preview is actually the key clue to what is happening here. Let me explain what is going on and how to fix it.

The swap preview you described tells the whole story. Look at it this way:

In the Source slot changes (staging), it shows the settings going to "Not set" meaning staging will lose those values after the swap. In the Target slot changes (production), it shows the old value as "Not set" and the new value as your expected setting meaning production will receive those values. This is actually the swap working correctly! The settings are being moved from staging to production as expected.

However, the real problem here is a subtler one. The swap preview is showing you that your production slot currently has no values set for those environment variables at all ("Not set" as the old value). This means your app in production may not be picking up the new values because either the app needs a restart to load them, or the values were not saved properly before the swap.

Here is what you should check and do step by step:

Step 1 — Verify the swap actually completed by checking production settings

After the swap, go directly to the production slot and confirm the values are really there.

  • In the Azure Portal, open your App Service.
  • Click on the Production slot (not staging).
  • Go to Settings > Environment variables.
  • Check if your expected env variable values are now showing there.

If they are present — great, the swap worked! Your app just might need a restart to pick them up (see Step 3).

Step 2 — Check if "Deployment slot setting" is accidentally enabled anywhere

Even though you mentioned it is NOT checked, it is worth double-checking every single variable individually, as it is easy to miss one.

  • Go to the staging slot in the portal.
  • Open Settings > Environment variables.
  • Click on each variable one by one and confirm the Deployment slot setting toggle is turned OFF for all of them.
  • If even one is toggled ON, that specific variable will stay in staging and never move to production during a swap.

Step 3 — Restart the production slot after the swap

Sometimes the app does not automatically pick up newly swapped environment variables without a restart.

  • Go to the Production slot in the Azure Portal.
  • Click Restart at the top of the Overview page.
  • Wait for it to come back up and then re-check if the env variables are being read by your application.

Step 4 — Understand the swap preview correctly going forward

This is important to avoid confusion in the future. The swap preview table works like this:

  • Source slot changes shows what the staging slot's settings will look like AFTER the swap (it will lose the values it gave to production).
  • Target slot changes shows what the production slot's settings will look like AFTER the swap (it will gain the values from staging).

So seeing "Not set" under source slot changes is completely expected and normal — it just means staging is giving away those values to production. The swap is working correctly.

Step 5 — If production still shows "Not set" after the swap

If after following the above steps the values are still missing in production, try this as a workaround:

  • Manually add the environment variables directly in the production slot as well (with their production-appropriate values).
  • Then on the next swap, both slots will have values and the swap preview will make more sense going forward.

To summarise based on the swap preview you shared, it looks like the swap is actually working as expected. The most likely culprits are either the app needing a restart to pick up the new values, or the production slot genuinely not having received them due to a "Deployment slot setting" being checked on one of the variables. A quick check of each variable's toggle and a production restart should resolve this for you.

If this answer helps you kindly accept the answer which will help others who have similar questions.

Best Regards,

Jerald Felix.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. AI answer

    2026-05-28T09:22:07.5+00:00

    App settings and connection strings are swapped between slots by default unless they’re explicitly marked as slot-specific (unswappable). If settings configured in the staging slot don’t appear in production after a swap, the most common cause is that those settings are configured as deployment slot settings (slot-specific) and therefore stay with the slot instead of moving with the code.

    To ensure settings move with the swap:

    1. Open the staging slot in the Azure portal.
    2. Go to Settings > Environment Variable.
    3. For each setting that should be swapped into production, make sure Deployment slot setting is not selected. If it is selected, that setting is slot-specific and won’t swap.
    4. Apply the changes and perform the slot swap again.

    If a setting should remain different between staging and production (for example, different connection strings), then it should be kept as a deployment slot setting (slot-specific) by leaving Deployment slot setting checked.

    The swap operation status of Succeeded or Accepted in logs confirms that the swap ran; it doesn’t override slot-specific configuration. The behavior seen in the Source slot changes and Target slot changes views is consistent with some settings being marked as slot-specific.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.