Azure Web App deploy: Web Deploy cannot modify the file on the destination because it is locked by an external process

前端 未结 11 810
甜味超标
甜味超标 2020-12-14 07:24

I am using the \"Azure Web App Deployment\" build step in VSTS to publish an ASP.NET Core API to an Azure Web App:

Occasionally, this step breaks with the f

相关标签:
11条回答
  • 2020-12-14 08:21
    1. Stop app service
    2. deploy code
    3. Start app service

    0 讨论(0)
  • 2020-12-14 08:21

    Eddie's answer was close to what I needed, the only thing that was missing was a way to specify the deployment slot:

    stopapp.ps1

    param($websiteName, $websiteSlot)
    $website = Get-AzureWebsite -Name $websiteName -Slot $websiteSlot
    Stop-AzureWebsite -Name $websiteName -Slot $websiteSlot
    

    startapp.ps1

    param($websiteName, $websiteSlot)
    $website = Get-AzureWebsite -Name $websiteName -Slot $websiteSlot
    Start-AzureWebsite -Name $websiteName -Slot $websiteSlot
    

    And then on your Azure PowerShell task Script Arguments could be something like this:

    -websiteName "{mywebsite}" -websiteSlot "{mydeploymentslot}"
    
    0 讨论(0)
  • 2020-12-14 08:24

    You can create two Power Shell scripts:

    stopapp.ps1:

    param($websiteName)
    $website = Get-AzureWebsite -Name $websiteName
    Stop-AzureWebsite -Name $websiteName
    

    startapp.ps1:

    param($websiteName)
    $website = Get-AzureWebsite -Name $websiteName
    Start-AzureWebsite -Name $websiteName
    

    And then add an "Azure PowerShell" task before and after "Azure Web App Deployment" task to stop the web app before deploy and start the app after deploy.

    0 讨论(0)
  • 2020-12-14 08:27

    Before you open too many cans of worms on this, wait 30-60 seconds and try publishing your app a second time. It appears that this sometimes happens because the stop request that gets issued to the service either returns before the service has completely stopped or maybe Visual Studio is not waiting long enough for this operation to finish. Each time I've encountered the problem, waiting and retrying the publish worked the second time.

    0 讨论(0)
  • 2020-12-14 08:28

    You can restart the Function App to release the lock. After that you should be able to deploy.

    0 讨论(0)
提交回复
热议问题