503/417 errors on Azure webapp deployment - azure

I have deployed an Azure Webapp via a slot-swap deployment in ADO with an ARM Template. The App Service Plan is "Always-On".
Every once in a while the app fails to swap (thus the deployment fails). The message is below:
##[warning]Error: Failed to update deployment history. Service Temporarily Unavailable (CODE: 503)
##[error]Error: Failed to swap App Service 'name' slots - 'Slot' and 'production'. Error: ExpectationFailed - Cannot swap site slots for site 'name' because the 'Slot' slot did not respond to http ping. (CODE: 417)
This is the result after 30min of waiting. When it is successful, it only takes a few minutes. More frustrating is the fact that the web is not actually down, it's working fine and not throwing any exceptions or 5xx

Turning off and turning back on the 'Auto-Swap' is one approach that you can try.
'Auto-Swap' can be turned on and off by going to 'App Service' > 'Deployment Center' >'Slot' > 'Configuration'.
Also, please refer the below links
Troubleshoot swaps ,
Troubleshooting steps to solve "502 bad gateway" and "503 service unavailable" errors

Related

Azure Function publish - "Timed out waiting for SCM to update the Environment Settings"

I've deployed and published several Function Apps without issues over the last 12 months. However, as of this week, when publishing a Function App using the following PowerShell script:
func azure functionapp publish <functionAppName> --java
I will receive the following error after a few minutes: "Timed out waiting for SCM to update the Environment Settings"
Similarly, I'm also unable to deploy any Function Apps, using:
mvn azure-functions:deploy
In the Function App activity log, the following error is logged for both cases:
Operation name: Sync Web Apps Function Triggers.
Status: Failed.
Error code: BadRequest (HTTP Status Code: 400)
Message: Encountered an error (InternalServerError) from host runtime.
So far I've created the Application setting WEBSITE_WEBDEPLOY_USE_SCM (value: true) based on feedback in another topic, which unfortunately hasn't helped. Other than that I've not been able to find much other information on this issue.
Does anyone have any thoughts?
Resolved this issue myself. The Application Setting WEBSITE_CONTENTAZUREFILECONNECTIONSTRING contained an outdated storage account key.

Terraform Azure Application Insights failing with 401 on random resources after Azure AD issues

I have a terraform library of different azure resources that were working fine the other day. Since the Azure AD failure I can't run a terraform plan anymore without random application insight resources failing due to 401 Unauthorized
Tried re-running az login but unfortunately still receiving issues.
Every plan is resulting in a different application insight resource throwing a 401.
Error: Error making Read request on AzureRM Application Insights
'{resource-name}': insights.ComponentsClient#Get: Failure responding
to request: StatusCode=401 -- Original Error: autorest/azure: Service
returned an error. Status=401 Code="Unauthorized"
Message="Unauthorized"
InnerError={"diagnosticcontext":"1b8e2cf0-5fd5-4a0d-9b75-1093e63ecd18","time":"2020-09-29T16:32:34.3731943Z"}
Have you tried re-initializing your Terraform backend? Doing this sequence just resolved the issue for me.
az login
terraform init
terraform plan

How to get more information about a failed Azure deployment?

I'm trying to automatically deploy a resource of type Microsoft.BotService/botServices on Azure and the deployment gets stuck endlessly retrying it while only giving me a "Internal server error (500)" message.
Is there any way to get more specific information?
Click on the resource group you're deploying to in the Portal.

Azure DevOps Release Pipeline Fails Every Time

Currently, trying to configure a release pipeline in Azure Devops. I've successfully created a CI pipeline that is working and running tests successfully. My release pipeline uses the artifacts from latest the CI build and should be deploying to azure. When I look at the logs I can see the the following were completed successfully:
Initialize Agent
Initialize job
Download arifact
and then the "Deploy to Azure App Service" fails with the logs showing the following details:
2019-02-07T19:06:57.5433805Z Got service connection details for Azure App Service:'MyApp'
2019-02-07T19:06:57.5487495Z ##[error]Error: Failed to get resource ID for resource type 'Microsoft.Web/Sites' and resource name 'MyAPP'. Error: Could not fetch access token for Managed Service Principal. Please configure Managed Service Identity (MSI) for virtual machine 'https://aka.ms/azure-msi-docs'. Status code: 400, status message: Bad Request
2019-02-07T19:06:57.5496340Z Failed to add release annotation. TypeError: Cannot read property 'getApplicationSettings' of undefined
I haven't been able to find much to help with this so far. I created the release pipeline by selecting Azure App Service deployment from the templates for stage 1 of the pipline (I only have one stage) and I added an artifact who's source is from my build pipeline. I then selected the Tasks tab and selected my Pay-as-you-go subscription under "Available Azure Service Connections". After selecting my subscription, my app service name became available in the "App service name" dropdown and I selected it. I then hit save and tried to create a release but every release fails with the above error message.
What can I do to overcome this?
Finally found a solution to my issue. The problem was in the way I set up my service connection. I went to:
project settings -> service connections -> new service connection -> selected azure resource manager -> selected service principal authentication INSTEAD OF managed identity authentication -> a popup came up that allowed me to log in and authorize.
Then I used that service connection when creating the release pipeline instead of the pre-existing Pay-As-You-Go subscription that I used last time.
Previously when I tried this, I had an adblocker running and it blocked the popup which allowed me to authorize when I selected service principal authentication. That resulted in an "Unable to authorize account" error message which is why I went with managed identity authentication in the first place.
In my case, it was related to a chrome extension I have added 'enable CORS' plugin. After disabling, release pipeline worked nicely

Error swap slot settings Release Management Visual Studio Team Services

In Release Management on Visual Studio Team Services I receive the following error:
"Code": "Conflict",
"Message": "The slot cannot be changed because its configuration settings have been prepared for swap.",
"ExtendedCode": "04081",
"MessageTemplate": "The slot cannot be changed because its configuration settings have been prepared for swap.",
From my Release management template in the "Azure Deployment" step, I have the following configuration:
Azure connection type: Azure Resource Manager
Action: Create or update Resourcegroup
Deployment mode: incremental
We have an ARM template with only appsettings we want to have applied to the production slot. the previous step in this release is a "Swap"
More info: we first release to some test slots, then a QA slot, which swaps with PROD.
This first occurred with a scheduled release (at midnight)
The slots are like this:
QA:
some steps (like blob copy),
final step: deploy a complete ARM template which creates the resources
PROD:
step 1: SWAP, with Azure App Service Manager (Preview)
step 2: ARM template with only AppSettings
Even a new build (which triggers a new release) still causes this error, any hints/clues?
I was able to figure out the root cause of this issue. If the Azure App Service Manager (Swap step) fails for some reason, in that case, Swap action does not get completed and leaves the App Service in inconsistent state.
If you go to the Azure portal and see the Overview of your App Service, 'Complete Swap' option is enabled instead of 'Swap'. Hence we should first Cancel or Complete the incomplete Swap. After doing that the deployment just works fine without this error.
We seemed to have this resolved
with only running step 2 in PROD (not perform a swap)
using another admins credentials
after trying several days
Not sure yet which one was the culprit.
The Azure App Service Manager (Preview) was used as a swap step

Resources