Troubleshooting app service slot swap failure issue

Greg Yvkoff 151 Reputation points
2022-09-15T20:40:05.237+00:00

I have a pipeline with an app service that fails to swap with the following error:

Warming-up slots  
Swapping App Service 'xxxxxxxx' slots - 'staging' and 'production'  
Successfully updated deployment History at https://xxxxxxxx-staging.scm.azurewebsites.net/api/deployments/338981663268841323  
Successfully updated deployment History at https://xxxxxxxx.scm.azurewebsites.net/api/deployments/338981663268841323  
##[error]Error: Failed to swap App Service 'xxxxxxxx' slots - 'staging' and 'production'. Error: BadRequest - Cannot swap slots for site 'xxxxxxxx' because the application initialization in 'staging' slot either took too long or failed. Please check AppInit module configuration or try using swap with preview if application initialization time is very long. (CODE: 400)  
##[section]Finishing: Swap Slots  

I checked the eventlog.xml file, and see this, which I do not quite understand:

<Event>  
    <System>  
        <Provider Name="Instrumentation Engine"/>  
        <EventID>1000</EventID>  
        <Level>1</Level>  
        <Task>0</Task>  
        <Keywords>Keywords</Keywords>  
        <TimeCreated SystemTime="2022-09-15T19:24:37Z"/>  
        <EventRecordID>1896924390</EventRecordID>  
        <Channel>Application</Channel>  
        <Computer>xxxxxxxxxxx</Computer>  
        <Security/>  
    </System>  
    <EventData>  
        <Data>IfFailRet(m_pAppDomainCollection-&gt;GetModuleInfoById(moduleId, &amp;pModuleInfo)) failed in function MicrosoftInstrumentationEngine::CProfilerManager::ClearILTransformationStatus</Data>  
    </EventData>  
</Event>  
  • The pipeline file is using task AzureAppServiceManage@0 to do the swap, and auto-swap is disabled
  • The web.config does not have an applicationInitialization section.
  • The app service does have WEBSITE_SWAP_WARMUP_PING_STATUSES=200,202 on both slots
  • The app service does have WEBSITE_ADD_SITENAME_BINDINGS_IN_APPHOST_CONFIG=1 on both slots
  • The app service does have HTTPS Only = off on both slots

When I reran the pipeline with system diagnostics enabled, I did see this:

##[debug][GET]http://xxxxxxx-staging.azurewebsites.net  
##[debug]Could not parse response: {}  
##[debug]Response: undefined  
##[debug]App Service status Code: '403'. Status Message: 'Ip Forbidden'  
##[debug]App Service status Code: '307'. Status Message: 'Temporary Redirect'  
Swapping App Service 'xxxxxxx' slots - 'staging' and 'production'  
##[debug][POST]https://management.azure.com/subscriptions/abcdefg/resourceGroups/rg1/providers/Microsoft.Web/sites/xxxxxxx/slots/staging/slotsswap?api-version=2016-08-01  
##[debug]Correlation ID from ARM api call response : 9ef48c6c-b6ff-44a9-9154-c55b9990b088  
##[debug]https://management.azure.com/subscriptions/abcdefg/resourceGroups/rg1/providers/Microsoft.Web/sites/xxxxxxx/slots/staging/slotsswap?api-version=2016-08-01 ==> undefined  
##[debug][GET]https://management.azure.com/subscriptions/abcdefg/resourceGroups/rg1/providers/Microsoft.Web/sites/xxxxxxx/slots/staging/operationresults/667d3675-3bb8-4964-8a9c-fe6fd7198795?api-version=2016- 1-Aug  
##[debug]Correlation ID from ARM api call response : 669cb941-f72c-4c76-82b1-299cf3ac1779  
##[debug]https://management.azure.com/subscriptions/abcdefg/resourceGroups/rg1/providers/Microsoft.Web/sites/xxxxxxx/slots/staging/operationresults/667d3675-3bb8-4964-8a9c-fe6fd7198795?api-version=2016-08-01 ==> undefined  
##[debug]Response status code : 202  
##[debug][GET]https://management.azure.com/subscriptions/abcdefg/resourceGroups/rg1/providers/Microsoft.Web/sites/xxxxxxx/slots/staging/operationresults/667d3675-3bb8-4964-8a9c-fe6fd7198795?api-version=2016- 1-Aug  
##[debug]Correlation ID from ARM api call response : b6ac6812-404b-4449-803e-a964b392078b  
##[debug]Response status code : 400  
##[debug]Completed action  

The troubleshooting documentation says to look at eventlog.xml file, but didn't find anything helpful, and there wasn't anything in the link that looked like could be the culprit.

However according to the system diagnostics, I do see this, but not sure if this is the culprit, or how to resolve it.

##[debug]App Service status Code: '403'. Status Message: 'Ip Forbidden'  
##[debug]App Service status Code: '307'. Status Message: 'Temporary Redirect'  

Any ideas?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,659 questions
{count} votes

1 answer

Sort by: Most helpful
  1. brtrach-MSFT 16,121 Reputation points Microsoft Employee
    2022-09-19T03:54:30.827+00:00

    @Greg Yvkoff We understand that you are encountering an issue where your deployments slot swapping is failing with an error.

    The last time we saw this, the solution was to place a 2-minute hold on swapping the slot. Is this wait period something you can integrate into your pipeline? This will allow any background tasks for the slot to complete for attempting to swap it.

    Please let us know if this solution works. If not, reply here so we can assist you further.


Your answer

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