Home > Blockchain >  Run .Net 6 code on App Service Plan (Linux )
Run .Net 6 code on App Service Plan (Linux )

Time:09-14

I am having Event Grid Trigger Azure Function(.Net 6 App) which is running on P2V2 plan (App Service) Windows OS. I am planning to run it on Linux OS in App Service hosting plan to save cost.

In Windows based App Service plan, I provide configuration settings in following way

[
  {
    "name": "APPINSIGHTS_INSTRUMENTATIONKEY",
    "value": "",
    "slotSetting": false
  },
  {
    "name": "ApplicationInsights:LogLevel",
    "value": "Information",
    "slotSetting": false
  },
  {
    "name": "AzureWebJobsStorage",    
     "value":"",
    "slotSetting": false
  },
  {
    "name": "Component:ComponentId",
    "value": "",
    "slotSetting": false
  }
]

While deploying to Linux based OS, ApplicationInsights:LogLevel config setting doesn't accept because of colon(:) is not supported. What should I do in that case to run in Linux OS in App Service hosting plan ?

CodePudding user response:

  • Dependency injection configuration is setup in function class file by default.
  • We need to add few configuration changes, Add logLevel settings in host.json file.

My host.json :

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    },
    "logLevel": {
      "AzureFunction.Sample": "Information"
    }
  }
}
  • APPINSIGHTS_INSTRUMENTATIONKEYand AzureWebJobsStorage are added in the local.settings.json file as below

My local.settings.json

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "APPINSIGHTS_INSTRUMENTATIONKEY": "Copy the Instrumentation Key from Application Insights"
  },

  "Component": {
    "ComponentId": "",
    "value": "",
    "slotSetting": false
  }
}

Hosted the App in Azure Linux Hosting Plan.

Application Insights Traces : enter image description here

  • Related