I'm using Terraform to create a slot on an azure app service but I need some of the app settings to be sticky. This is normally done using the "slotConfigNames" in ARM but doesn't seem to be possible in Terraform.
Is this possible?
https://www.terraform.io/docs/providers/azurerm/r/app_service_slot.html
Thanks
It is not possible to use azurerm_app_service_slot directly since the Sticky Slot settings are not supported in terraform. But you can make use of the Azure Template Deployment resource in Terraform.
The solution will create an App Service with one or more Slots
attached to it and will also make use of Slot settings in order to
have the configuration tied to the environment as opposed to transform
a config file with a CI/CD server such as Octopus Deploy or perhaps
use multiple appSettings.json for each environment as you would on a
.net application.
You can get more details from this blog.
This has ben implemented now in v3.4.0 of the AzureRM provider.
terraform-provider-azurerm 3.4.0 (April 28, 2022) release notes
terraform documentation: sticky_settings
UPDATE: after some investigation into the AZ powershell module for sticky settings (Set-AzWebAppSlotConfigName), I realized that you don't need to set this on the terraform slot resource - you just set it on the primary resource (production slot).
The sticky_settings block has been added to the parent resources (app service, function app), but not the slot.
Related
I have a terraform module that creates app service environment using an ARM template and I am planning to move to terraform module azurerm_app_service_encironment as arm templates are getting deprecated.
When I search the terraform repo with app service environment here , I get module azurerm_app_service_Environment and azurerm_app_service_environment_v3. I am currently using ASEV2, how do I create that using terraform? I see V3 has a separate module, what about V2?
Also my ARM template is using params like dnsSuffix which I cannot find in ASE terraform module but exist in ASE version 3.
There is no document available in terraform for azurerm_app_service_environment_v2 but if you are planning to Migrate App Service Environment v3 from azurerm_app_service_environment_v2 using ARM so you can refer this document :
Also there is feature difference between azurerm_app_service_environment and azurerm_app_service_environment_v3 so few features available in update version that not in earlier version so that is the reason dns_suffix is not there in azurerm_app_service_environment.
I tried to create app_service_enviroment from portal you only have option to create App Service Environment v3(Latest).
Note : After 31 August 2024, if you haven't migrated to App Service Environment v3, your App Service Environment v1/v2s and the apps deployed in them will no longer be available.
In azure when i go to an App Service -> Settings -> Configuration -> Path mappings i see the following:
Now let's suppose i want to add more path mappings to it how can i do it, without using App service slots, how can we implement something like this with terraform?
example of what i pretend:
I found an github answer from the terraform providers that involved an azure template deploy using App Service Slots.
https://github.com/terraform-providers/terraform-provider-azurerm/issues/1422
Anyone found a way of doing this?
It looks like this is not yet possible in Terraform. According to this post on GitHub, you can add more path mappings via a PowerShell script once Terraform has finished provisioning its resources.
is there any code generator for Azure Terraform?
Actually i am trying to add Azure app service to existing resource group. For this we need a state configuration file, which can be generated only ( Terraform import ) if we have full Terraform code already written for that resource group.
I saw, Using Terraform to import existing resources on Azure and Update existing app service with Terraform ,but here i am talking about the thousands of resource groups.
Thanks
Gill
You would, to my knowledge, need to use terraform import against all of the existing resources that you have / want to consumse via terraform.
In saying that if you only want to manage the Azure App Service with Terraform and not everything else you can just simply pass all the requirements for the resource in and only manage this in the terraform state file.
Hi Lachie thanks for reply, I Found the solution using AZ2TF tool.
Thanks to Mr Agarciamiravet, who explained all the steps to use AZ2TF tool ( by using Docker) at
https://recetasdevops.com/migra-tu-infraestructura-actual-de-azure-a-terraform-con-py-az2tf/
this worked very well for me.
Thanks
Gill
I have created a Function App for Containers using ARM template deployment using Azure DevOps Pipeline job (Azure Resource Group Deployment).
After deployment added additional configurations other than default configurations for Function App through portal.
For adding new resources, I have updated my 'template.json' and redeployed again. But this removes all my manual configuration of the existing Function App and set it to the default config settings in the template file. :( . Anyone please tell me a way for sort this problem.
Is there any property that helps to retain the resources and its configuration unchanged while deployment using ARM ? I used the property
"mode":
"Incremental" .
But this didn't work for me. It removes the existing configurations that I have created manually. Please suggest a best way to deploy and manage a resource using ARM. Is there any property or 'key : value' for adding additional settings to site config other than remove the site config and recreate it as inside the template default.
I think your only option is to set those configurations into the ARM template. ARM templates are not always incremental but are some time declarative as in this case.
You can switch to bicep, which has the ability to merge app settings. However, I don't have the details at the moment.
bicep wouldn't be a valid path to take. Except you can generate bicep from your source arm templates if they are 2019 or newer. That way the arm temples still drives the pipeline.
I wonder if terraform has the same options?
I am working in a project that will be deployed at my client's Microsoft Azure. Thus I am currently testing terraform to assist me when the time comes.
create a azure function with terraform that will trigger on blob storage input data
My question is about how to add the azure functions's javascript/c# code into the terraform script so it will be automatically deployed ?
I checked the terraform docs, but it wasn't of much help:
https://www.terraform.io/docs/providers/azurerm/r/function_app.html
Any ideas?
Terraform doesn't handle pushing code to Azure resources, that's usually done in a following step in the pipeline (e.g. 1- execute terraform 2- deploy code).
However, the Azure Function App does have the ability to connect directly to your repo, and the Terraform azurerm_function_app module exposes the source_control property.
Terraform's azurerm_function_app documentation
So with Terraform you can configure the function app to pull the code directly from the repo when a change is detected.
Microsoft's Azure Function Continuous Deployment documentation