Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify .net core version with Terraform azurerm_app_service

Out of the box, I think azurerm_app_service provider does allow us to specify the .Net framework version, by utilising the dotnet_framework_version field.

dotnet_framework_version - (Optional) The version of the .net framework's CLR used in this App Service. Possible values are v2.0 (which will use the latest version of the .net framework for the .net CLR v2 - currently .net 3.5) and v4.0 (which corresponds to the latest version of the .net CLR v4 - which at the time of writing is .net 4.7.1). For more information on which .net CLR version to use based on the .net framework you're targeting - please see this table. Defaults to v4.0.

https://www.terraform.io/docs/providers/azurerm/r/app_service.html#dotnet_framework_version

The document says that the possible values are v2.0 or v4.0.

But what if I am targeting .NET Core, say v2.2 instead? What am I supposed to do here?

Azure portal allows selecting .NET Core from the drop down menu. (see screenshot below)

enter image description here

I am not sure whether or not there's a way to do this with Terraform azurerm_app_service as well.

like image 455
woodykiddy Avatar asked Jun 13 '19 03:06

woodykiddy


1 Answers

You need to specify the following 2 settings in site_config block of the app_service block. for e.g.

resource "azurerm_app_service" "app_service" {
  name                = local.graphql_server_long_name
  location            = var.azure_region
  resource_group_name = azurerm_resource_group.rg.name
  app_service_plan_id = azurerm_app_service_plan.graphql_server.id
  site_config {
    linux_fx_version = "DOTNETCORE|5.0"
    dotnet_framework_version = "v5.0"
  }

those are linux_fx_version and dotnet_framework_version.

You need to be running at least 2.38.0 version of azurerm provider. You can check this by running the following command in the directory which contains your terraform files: terraform version

This will display the terraform cli and all used providers.

like image 103
adeel41 Avatar answered Sep 18 '22 18:09

adeel41