Search code examples
azuresecurityazure-functionsazure-managed-identity

Azure Function failling with error: The username or password incorrect: C:\host\LogFiles\Application\Function\Host


Getting the following error in function app on azure portal: The username or password incorrect: C:\host\LogFiles\Application\Function\Host

We had created a function app which was on consumption plan, but we switched it to dedicated host - P3V2 in order to use MSI based auth with storage account. We have deleted the variables AzureWebJobsStorage, WEBSITE_CONTENTSHARE and WEBSITE_CONTENTAZUREFILECONNECTIONSTRING and instead added AzureWebJobsStorage__accountName containing the name of the storage account. We have given the following permissions in the storage account: enter image description here

And getting the following error: enter image description here

What am i missing here?


Instead of manually doing all the changes, I made changes to the artifacts (ARM Templates) and deployed all the resources again, after which this issue was gone, but another issue surfaced.

enter image description here

We deployed the following bicep file for azure function:

param functionAppName string

@description('Packaged build')
param servicePackageLink string = ''

@description('App service hosting plan id')
param hostingPlanId string

@description('Allows user to target a region other than the resource group region.')
param location string = resourceGroup().location

@description('Additional configs to be set in the function enviroment variable')
param configs array = []

param storageAccountName string

param storageAccountId string

@secure()
param appInsightsInstrumentationKey string

// Service Configurations
// -----------------------------------------------------------------------------------------------

var defaultAzureFunctionsConfigs = [
  {
    name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
    value: appInsightsInstrumentationKey
  }
  {
    name: 'AzureWebJobsStorage__accountName'
    value: '${storageAccountName}'
  }
  {
    name: 'FUNCTIONS_EXTENSION_VERSION'
    value: '~4'
  }
  {
    name: 'FUNCTIONS_WORKER_RUNTIME'
    value: 'dotnet'
  }
  {
    name: 'WEBSITE_RUN_FROM_PACKAGE'
    value: '0'
  }
  {
    name: 'WEBSITE_FIRST_PARTY_ID'
    value: 'AntMDS'
  }
  {
    name: 'WEBSITE_LOAD_USER_PROFILE'
    value: '1'
  }
  // WEBSITE_CONTENTSHARE will also be auto-generated - https://docs.microsoft.com/en-us/azure/azure-functions/functions-app-settings#website_contentshare
  // WEBSITE_RUN_FROM_PACKAGE will be set to 1 by func azure functionapp publish
]

// Resources
// -----------------------------------------------------------------------------------------------


resource functionApp 'Microsoft.Web/sites@2020-06-01' = {
  name: functionAppName
  location: location
  kind: 'functionapp'
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
    httpsOnly: true
    serverFarmId: hostingPlanId
    clientAffinityEnabled: true
    siteConfig: {
      alwaysOn: false
      appSettings: concat(defaultAzureFunctionsConfigs, configs)
      minTlsVersion: '1.2'
    }
  }
}

resource zipDeploy 'Microsoft.Web/sites/extensions@2022-03-01' = {
  parent: functionApp
  name: 'MSDeploy'
  properties: {
    packageUri: servicePackageLink
    appOffline: true
  }
}
// Outputs
// -----------------------------------------------------------------------------------------------

output ResourceId string = functionApp.id
output FunctionAppName string = functionApp.name
output PrincipalId string = functionApp.identity.principalId

Service Plan being used is P3V2. The deployment happens successfully but the function app doesn't come up.

On Azure portal is throws the following error: enter image description here

Config for azure function: enter image description here


Solution

  • The error was resolved once I updated the version of the DurableTask Version to >= 2.7.0