简体   繁体   中英

Azure Function App - Swap deployment Slots stuck then crashing completely

Recently my function apps have stopped swapping slots, they worked fine for months but suddenly they have all stopped swapping by taking a long time then crashing. I have recreated the function apps using the same scripts and have replicated the issue but still can't fix.

Is there anything I am setting to stop the slots from switching?

Here is the fundamental build script I am using. I am able to run this but when trying to swap slots in Azure it freezes then crashes with a vague error message:

 # Azure Login
az login

# Set deployment Environment
$environment = "stage"

# Resource Group Variables
$subscriptionId = ""
$domain = "test4"
$resourceGroup = "xx-platform-$domain-$environment"
$region = "northEurope"

# Functions app variables
$storageName = "xxfn$domain$environment" # must be less than 24 chars and all lower case
$functionAppDeploymentSlotName = "test"
$functionAppName = "xx-platform-$domain-fn-$environment"
$functionAppEnvironment = "AZURE_FUNCTIONS_ENVIRONMENT=Development"
$websiteRunFromPackage = "WEBSITE_RUN_FROM_PACKAGE=1"

#########################################################################################################################################################################
## Resource Group
Write-output "Creating resource group";

# Set subscription
az account set --subscription $subscriptionId

# Create resource group
az group create -l $region -n $resourceGroup  

#########################################################################################################################################################################
## Functions App
Write-output "Creating Functions App";

# Create storage account
az storage account create --name $storageName --location $region --resource-group $resourceGroup --sku Standard_LRS

# Create functions app - using consumption plan
az functionapp create --name $functionAppName --storage-account $storageName --consumption-plan-location northEurope --resource-group $resourceGroup --functions-version 4

# Set functions app configuration settings

# Environment
az functionapp config appsettings set --name $functionAppName --resource-group $resourceGroup --settings $functionAppEnvironment 
# WEBSITE_RUN_FROM_PACKAGE 
az functionapp config appsettings set --name $functionAppName --resource-group $resourceGroup --settings $websiteRunFromPackage 
# SET DOT NET FRAMEWORK ERSION
az functionapp config set --net-framework-version v6.0 -g $resourceGroup -n $functionAppName


# Create functions app deployment slot
az functionapp deployment slot create --name $functionAppName  --resource-group  $resourceGroup --slot $functionAppDeploymentSlotName 

I have modified your script in initializing the variable values directly to the cmdlets:

# Azure Login
az login
az account set --subscription "<Ur_Azure_Subscription_Id>"

# Function App Create
az functionapp create --name dt-platform-fn-stage --storage-account dtfnstageenvironment --consumption-plan-location northEurope --resource-group HariTestRG --runtime dotnet --functions-version 4

# Environment
az functionapp config appsettings set --name dt-platform-fn-stage --resource-group HariTestRG --settings AZURE_FUNCTIONS_ENVIRONMENT=Development

# WEBSITE_RUN_FROM_PACKAGE
az functionapp config appsettings set --name dt-platform-fn-stage --resource-group HariTestRG --settings WEBSITE_RUN_FROM_PACKAGE=1

# SET DOT NET FRAMEWORK ERSION
az functionapp config set --net-framework-version v6.0 -g HariTestRG -n dt-platform-fn-stage

# Create functions app deployment slot

az functionapp deployment slot create --name dt-platform-fn-stage --resource-group HariTestRG --slot test

在此处输入图像描述

Created the Http Trigger Function using the cmdlets given in the below given MS Document.

For Continuous deployments, this app setting needs to be configured:

az functionapp config appsettings set --name dt-platform-fn-stage --resource-group HariTestRG --settings "SCM_DO_BUILD_DURING_DEPLOYMENT=true"

Deployed the Function to the Azure Functions using az cli cmdlet given in one of my workarounds.

By default, Auto Swap on Slots will be disabled:在此处输入图像描述

It is working fine during the slot swapping and make sure you have followed the considerations mentioned in this MS Doc that also provides the list of az cli cmdlets for managing the slots like creating, listing, deleting, swapping and auto swapping configuration.

Above Azure CLI Commands have been taken from this MS Doc references.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM