Suppose that, we need to create a Azure CDN on PROD with BLUE-GREEN concept. So, we should only have a custom domain but behind the sense, the static data should be stored separately on individual Strorage Account.
This will help avoid impact when we would like to update new data
In order to do this scenarios, we create 2 storages accounts name, for example: dev, test
Fist, creating a resource group using Terraform
resource "azurerm_resource_group" "rg" {
name = "rg-courses-non-prod-weu-infra"
location = "westeurope"
tags = {
Owner="courses"
}
}
Next, create 2 storage accounts
resource "azurerm_storage_account" "st_dev" {
name = "stcoursesdevweu"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
account_tier = "Standard"
account_replication_type = "LRS"
min_tls_version = "TLS1_2"
tags = {
Owner="courses"
}
}
resource "azurerm_storage_account" "st_test" {
name = "stcoursestestweu"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
account_tier = "Standard"
account_replication_type = "LRS"
min_tls_version = "TLS1_2"
tags = {
Owner="courses"
}
}
Now, we are going to create Azure CDN profile, and Azure CDN profile
resource "azurerm_cdn_profile" "cdnp" {
name = "cdnp-courses-non-prod-weu"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
sku = "Standard_Microsoft"
tags = {
Owner="courses"
}
}
resource "azurerm_cdn_endpoint" "cdne" {
name = "cdne-courses-non-prod-weu"
profile_name = azurerm_cdn_profile.cdnp.name
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
origin {
name = "origin-dev"
host_name = azurerm_storage_account.st_dev.primary_blob_host
}
}
Noted: currently, Terraform version 3.62.1 (latest version 26 June, 2023) haven't support creating multiple origin and origin group then we have to do this action manually.
Step 1: Select Azure CDN profile and choose the Endpoints
Select Origin in Setting section at left panel.
We will create one more origin, but in order to create more origin we have to create 2 origin groups
Finnaly, we have to create Rules engine to route traffic. For the Rules engine the Azure offer 5 rules as free. If you create more than 5 rules it will be charged
1. Create a container name matches with the value of operator. It is also change the public access level to Blob (anonymous read access for blobs only)
for example: blue container it will have an image
and green container it will have an image
For the Blue Url
0 Comments
Post a Comment