Merge pull request #316 from TomArcherMsft/UserStory208753
User Story 208753 - App Service Backup
This commit is contained in:
commit
189718f6c1
22
quickstart/101-app-service-backup/README.md
Normal file
22
quickstart/101-app-service-backup/README.md
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# Azure Windows Web App with Backup
|
||||||
|
|
||||||
|
This template deploys an Azure Windows Web App with a backup configured.
|
||||||
|
|
||||||
|
## Terraform resource types
|
||||||
|
|
||||||
|
- [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet)
|
||||||
|
- [azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group)
|
||||||
|
- [random_string](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string)
|
||||||
|
- [azurerm_storage_account](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account)
|
||||||
|
- [azurerm_storage_container](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_container)
|
||||||
|
- [azurerm_service_plan](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/service_plan)
|
||||||
|
- [azurerm_windows_web_app](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/windows_web_app)
|
||||||
|
|
||||||
|
## Variables
|
||||||
|
|
||||||
|
| Name | Description | Default value |
|
||||||
|
|-|-|-|
|
||||||
|
| `resource_group_name_prefix` | Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription. | rg |
|
||||||
|
| `resource_group_location` | Location of the resource group. | eastus |
|
||||||
|
|
||||||
|
## Example
|
121
quickstart/101-app-service-backup/main.tf
Normal file
121
quickstart/101-app-service-backup/main.tf
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
resource "random_pet" "rg_name" {
|
||||||
|
prefix = var.resource_group_name_prefix
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "azurerm_resource_group" "rg" {
|
||||||
|
location = var.resource_group_location
|
||||||
|
name = random_pet.rg_name.id
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "random_string" "storage_account_name" {
|
||||||
|
length = 8
|
||||||
|
lower = true
|
||||||
|
numeric = false
|
||||||
|
special = false
|
||||||
|
upper = false
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "azurerm_storage_account" "example" {
|
||||||
|
name = random_string.storage_account_name.result
|
||||||
|
resource_group_name = azurerm_resource_group.rg.name
|
||||||
|
location = azurerm_resource_group.rg.location
|
||||||
|
account_tier = "Standard"
|
||||||
|
account_replication_type = "LRS"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "random_string" "storage_container_name" {
|
||||||
|
length = 8
|
||||||
|
lower = true
|
||||||
|
numeric = false
|
||||||
|
special = false
|
||||||
|
upper = false
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "azurerm_storage_container" "example" {
|
||||||
|
name = random_string.storage_container_name.result
|
||||||
|
storage_account_name = azurerm_storage_account.example.name
|
||||||
|
container_access_type = "private"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "random_string" "service_plan_name" {
|
||||||
|
length = 8
|
||||||
|
lower = true
|
||||||
|
numeric = false
|
||||||
|
special = false
|
||||||
|
upper = false
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "azurerm_service_plan" "example" {
|
||||||
|
name = random_string.service_plan_name.result
|
||||||
|
location = azurerm_resource_group.rg.location
|
||||||
|
resource_group_name = azurerm_resource_group.rg.name
|
||||||
|
os_type = "Windows"
|
||||||
|
sku_name = "S1"
|
||||||
|
}
|
||||||
|
|
||||||
|
data "azurerm_storage_account_sas" "example" {
|
||||||
|
connection_string = azurerm_storage_account.example.primary_connection_string
|
||||||
|
https_only = true
|
||||||
|
|
||||||
|
resource_types {
|
||||||
|
service = false
|
||||||
|
container = false
|
||||||
|
object = true
|
||||||
|
}
|
||||||
|
|
||||||
|
services {
|
||||||
|
blob = true
|
||||||
|
queue = false
|
||||||
|
table = false
|
||||||
|
file = false
|
||||||
|
}
|
||||||
|
|
||||||
|
# Please change the start_date variable (in variables.tf) to the appropriate
|
||||||
|
# value for your environment.
|
||||||
|
start = formatdate(var.start_date, timestamp())
|
||||||
|
expiry = formatdate(var.start_date, timeadd(timestamp(), "8765h"))
|
||||||
|
|
||||||
|
permissions {
|
||||||
|
read = false
|
||||||
|
write = true
|
||||||
|
delete = false
|
||||||
|
list = false
|
||||||
|
add = false
|
||||||
|
create = false
|
||||||
|
update = false
|
||||||
|
process = false
|
||||||
|
tag = false
|
||||||
|
filter = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "random_string" "windows_web_app_name" {
|
||||||
|
length = 8
|
||||||
|
lower = true
|
||||||
|
numeric = false
|
||||||
|
special = false
|
||||||
|
upper = false
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "azurerm_windows_web_app" "example" {
|
||||||
|
name = random_string.windows_web_app_name.result
|
||||||
|
location = azurerm_resource_group.rg.location
|
||||||
|
resource_group_name = azurerm_resource_group.rg.name
|
||||||
|
service_plan_id = azurerm_service_plan.example.id
|
||||||
|
|
||||||
|
backup {
|
||||||
|
name = "Example"
|
||||||
|
storage_account_url = "https://${azurerm_storage_account.example.name}.blob.core.windows.net/${azurerm_storage_container.example.name}${data.azurerm_storage_account_sas.example.sas}&sr=b"
|
||||||
|
schedule {
|
||||||
|
frequency_interval = 30
|
||||||
|
frequency_unit = "Day"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
site_config {
|
||||||
|
application_stack {
|
||||||
|
dotnet_version = "v6.0"
|
||||||
|
current_stack = "dotnet"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
23
quickstart/101-app-service-backup/outputs.tf
Normal file
23
quickstart/101-app-service-backup/outputs.tf
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
output "resource_group_name" {
|
||||||
|
value = azurerm_resource_group.rg.name
|
||||||
|
}
|
||||||
|
|
||||||
|
output "storage_account_name" {
|
||||||
|
value = azurerm_storage_account.example.name
|
||||||
|
}
|
||||||
|
|
||||||
|
output "storage_container_name" {
|
||||||
|
value = azurerm_storage_container.example.name
|
||||||
|
}
|
||||||
|
|
||||||
|
output "service_plan_name" {
|
||||||
|
value = azurerm_service_plan.example.name
|
||||||
|
}
|
||||||
|
|
||||||
|
output "windows_web_app_name" {
|
||||||
|
value = azurerm_windows_web_app.example.name
|
||||||
|
}
|
||||||
|
|
||||||
|
output "windows_web_app_default_hostname" {
|
||||||
|
value = azurerm_windows_web_app.example.default_hostname
|
||||||
|
}
|
18
quickstart/101-app-service-backup/providers.tf
Normal file
18
quickstart/101-app-service-backup/providers.tf
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">=1.0"
|
||||||
|
|
||||||
|
required_providers {
|
||||||
|
azurerm = {
|
||||||
|
source = "hashicorp/azurerm"
|
||||||
|
version = "~>3.0"
|
||||||
|
}
|
||||||
|
random = {
|
||||||
|
source = "hashicorp/random"
|
||||||
|
version = "~>3.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
provider "azurerm" {
|
||||||
|
features {}
|
||||||
|
}
|
18
quickstart/101-app-service-backup/variables.tf
Normal file
18
quickstart/101-app-service-backup/variables.tf
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
variable "resource_group_name_prefix" {
|
||||||
|
type = string
|
||||||
|
default = "rg"
|
||||||
|
description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "resource_group_location" {
|
||||||
|
type = string
|
||||||
|
default = "eastus"
|
||||||
|
description = "Location of the resource group."
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
variable "start_date" {
|
||||||
|
type = string
|
||||||
|
default = "2024-06-01"
|
||||||
|
description = "Start date."
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user