@Hector Huerta Tricolor Thank you for reaching out to Microsoft Q&A. Apologize for the inconvenience caused on this. Based on the shared information I have understood that you are trying to create Web App and also enabling the custom backup to it using Terraform.
I have created the below Terraform script which create a Webapp, storage account and also it enables the custom backup using the existing app service plan and I have tested this it is working fine I would suggest to validate from your end as well.
Here is the sample terraform script :
provider "azurerm" {
features {}
}
data "azurerm_resource_group" "rggroup" {
name = "<ResourceGroupName>"
}
data "azurerm_service_plan" "appplan"{
name= "<AppServicePlan>"
resource_group_name=data.azurerm_resource_group.rggroup.name
}
variable "app_name"{
type=string
default="<WebAppName>"
}
variable "storage_name"{
type=string
default="<StorageAccountName"
}
resource "azurerm_storage_account" "backupaccount" {
name= var.storage_name
location = data.azurerm_resource_group.rggroup.location
resource_group_name = data.azurerm_resource_group.rggroup.name
access_tier = "Hot"
account_tier = "Standard"
account_replication_type = "LRS"
account_kind = "BlobStorage"
}
resource "azurerm_storage_container" "backupcontainer" {
name ="<ContainerName>"
storage_account_name = azurerm_storage_account.backupaccount.name
container_access_type = "container"
}
data "azurerm_storage_account_blob_container_sas" "containersas"{
connection_string = azurerm_storage_account.backupaccount.primary_connection_string
container_name = azurerm_storage_container.backupcontainer.name
https_only = true
start = "2022-11-23T12:20:23Z"
expiry = "2022-11-24T00:00:00Z"
permissions {
read = true
add = true
create = true
write = true
delete = true
list = true
}
}
resource "azurerm_windows_web_app" "config" {
name = var.app_name
location = data.azurerm_resource_group.rggroup.location
resource_group_name = data.azurerm_resource_group.rggroup.name
service_plan_id = data.azurerm_service_plan.appplan.id
site_config {
always_on = true
ftps_state = "FtpsOnly"
managed_pipeline_mode = "Integrated"
use_32_bit_worker = false
application_stack {
current_stack = "dotnet"
dotnet_version= "v6.0"
}
}
backup{
name = "testbackup"
schedule{
frequency_interval =1
frequency_unit ="Day"
retention_period_days = 30
start_time = "2022-11-23T10:33:28.000Z"
}
storage_account_url = "https://${resource.azurerm_storage_account.backupaccount.name}.blob.core.windows.net/${resource.azurerm_storage_container.backupcontainer.name}${data.azurerm_storage_account_blob_container_sas.containersas.sas}"
}
}
Here is the sample output for your reference:
Feel free to reach back to me if you have any further questions on this.