papakpmartin
papakpmartin

Reputation: 323

Azure Functions: Deploying to stage slot also deploys to production slot

I have an Azure Function App v3 running a Node.js app that has a production and a stage slot. It gets deployed to from GitHub using an Action created in Deployment Center. I have one deploy action for prod and one for stage, and have verified that the prod deploy is not running.

When the stage deploy Action runs it is successful, but the code ends up in both the stage and production environments.

"Auto-swap enabled" is Off. I have not manually triggered a swap, either.

For stg the YAML looks like this:

- name: 'Run Azure Functions Action'
  uses: Azure/[email protected]
  id: fa
  with:
    app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
    package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
    publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE_STAGE }}
    slot-name: 'stg'

For production the YAML looks like this:

- name: 'Run Azure Functions Action'
  uses: Azure/[email protected]
  id: fa
  with:
    app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
    package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
    publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }}
    slot-name: 'production'

These both appear to match what is auto-generated by Deployment Center for each of the slots.

Upvotes: 3

Views: 1715

Answers (1)

papakpmartin
papakpmartin

Reputation: 323

The problem was that Configuration > Application settings > WEBSITE_CONTENTSHARE on the stg slot was identical to the production slot.

So I believe this meant that deliverables from either deploy were being dropped into the same storage location. So stage deploys were effectively overwriting prod code!

I think the stg slot was created using the Portal, so I guess this is just something to look out for.

Based on what I've learned today, I'd recommend making sure that every slots' WEBSITE_CONTENTSHARE is unique.

What I don't know right now is whether that setting should also be a "Deployment slot setting". It kind of seems like it should, but maybe that will make a swap not work properly?

I wouldn't have found this without https://stackoverflow.com/a/50824960/12031280 by @ahmelsayed

Upvotes: 3

Related Questions