Skip to content

Instantly share code, notes, and snippets.

@ninjarobot
Last active June 18, 2021 03:37
Show Gist options
  • Save ninjarobot/668bd5e3d2368391d51a08f357bd4d05 to your computer and use it in GitHub Desktop.
Save ninjarobot/668bd5e3d2368391d51a08f357bd4d05 to your computer and use it in GitHub Desktop.
Farmer application with multiple resource groups and traffic manager
#r "nuget: Farmer, 1.6.0"
open Farmer
open Farmer.Builders
open Farmer.Builders.ContainerGroups
open Farmer.Builders.TrafficManager
open Farmer.TrafficManager
let msi = userAssignedIdentity {
name "my-app"
}
let containerApp =
containerGroup {
name "my-containers"
add_identity msi
public_dns "my-container-app-1234" [ TCP, 80us ]
add_instances [
containerInstance {
name "web"
image "nginx"
add_public_ports [ 80us ]
probes [
liveliness {
http "http://localhost:80/"
initial_delay_seconds 15
}
]
}
]
}
arm {
add_resources [
resourceGroup {
name "global-rg"
location Location.EastUS
add_resources [
trafficManager {
name "tm-app-global"
routing_method RoutingMethod.Performance
add_endpoints [
endpoint {
name "eastus-app"
weight 1
priority 1
target_external "my-container-app-1234.eastus.azurecontainer.io" Location.EastUS
}
endpoint {
name "westus-app"
weight 1
priority 2
target_external "my-container-app-1234.westus.azurecontainer.io" Location.WestUS
}
endpoint {
name "westeu-app"
weight 1
priority 3
target_external "my-container-app-1234.westeurope.azurecontainer.io" Location.WestEurope
}
endpoint {
name "india-app"
weight 1
priority 4
target_external "my-container-app-1234.centralindia.azurecontainer.io" Location.CentralIndia
}
endpoint {
name "asia-app"
weight 1
priority 5
target_external "my-container-app-1234.eastasia.azurecontainer.io" Location.EastAsia
}
]
}
]
}
resourceGroup {
name "app-westus-rg"
location Location.WestUS
add_resources [
msi
containerApp
]
}
resourceGroup {
name "app-eastus-rg"
location Location.EastUS
add_resources [
msi
containerApp
]
}
resourceGroup {
name "app-westeu-rg"
location Location.WestEurope
add_resources [
msi
containerApp
]
}
resourceGroup {
name "app-asia-rg"
location Location.EastAsia
add_resources [
msi
containerApp
]
}
resourceGroup {
name "app-india-rg"
location Location.CentralIndia
add_resources [
msi
containerApp
]
}
]
} |> Writer.quickWrite "global-app"
@ninjarobot
Copy link
Author

Cleanup

az group delete -g global-rg -y --no-wait
az group delete -g app-eastus-rg -y --no-wait
az group delete -g app-westus-rg -y --no-wait
az group delete -g app-westeu-rg -y --no-wait
az group delete -g app-india-rg -y --no-wait
az group delete -g app-asia-rg -y --no-wait

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment