Publish-AzWebApp throws an error when uploading the Source Code for the aplication. The code is the following:
$job = Publish-AzWebApp `
-WebApp $webApp `
-ArchivePath (Join-Path -Path $rootPath -ChildPath $archiveRelativePath) `
-Force `
-AsJob
# # #
# ...code...
# # #
# Later on
$job | Receive-Job -AutoRemoveJob -Wait -WriteJobInResults | ForEach-Object {
if ("AzureLongRunningJob" -eq $_.GetType().BaseType.Name) {
if ("Completed" -eq $_.JobStateInfo.State) {
Write-Log -Message "Published the Source Code for $($webApp.Name) successfully." -Level INFO
}
else {
Write-Log -Message $_.JobStateInfo -Level ERROR
throw $_.JobStateInfo
}
}
}
The error is the following:
Deployment failed with status code ServiceUnavailable
+ CategoryInfo : InvalidResult: (:) [], Exception
+ FullyQualifiedErrorId :
The thing is that between the beginning of the job and the end of the job I am also uploading WebJobs and and also I'm setting the AppSettings from the Configuration Blade.
I also noticed that this happens when I am creating the app then doing this procedure in one go. But if the app exists, the error is less likely to occur. Still it doesn't seem like it is stable. What could I do?