Create cosmos db in another region, but in same deployment #943
-
Hi! I have a bunch of resources in West Europe, but need to create cosmos db in another region. At the moment I'm using this workaround : arm {
location envSettings.PrimaryLocation
add_resources [virtualNetwork; privateDnsZone]
add_resources [webAppsIdentity]
add_resources [persistentStorageAccount; temporaryStorageAccount; versionedStorageAccount; kv]
add_resources [apisAi]
add_resources [
resourceGroup {
name "[resourceGroup().name]"
deployment_name "cosmosdb_canadaeast"
location Location.CanadaEast
add_resource cosmodb
}
]
...
...
add_tags envSettings.Tags
} But it creates a nested deployment, so other resources cannot use |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
You could do it as a two step deployment i.e. first deploy the CosmosDB resource, and then a second deployment that uses the ResourceId of the CosmosDB instance as a "weak" link. @TheRSP I know that you worked on a lot of the resource group deployment stuff - any thoughts here? |
Beta Was this translation helpful? Give feedback.
-
Personally, I've got around this issue with an extension on the deployment builder. Something like this: [<CustomOperation "add_resources_in_location">]
member this.AddInLocation (state, location, resources) =
this.AddArmResources(state, resources |> List.collect (fun x -> x.BuildResources location)) (Apologies for code quality, I'm writing on a phone) However given that farmer bakes-in the location of a resource as part of the add_resources call, you can change the location of the resource group and this won't affect any resource which has already been added. arm {
location EastUS
add_resources eastUsResources
location CanadaEast
add_resources canadaEastResources
} |
Beta Was this translation helpful? Give feedback.
-
@TheRSP feel free to create that as a PR etc. - no problems with that from my side (although I would recommend documenting it as well to explain the use case for it). |
Beta Was this translation helpful? Give feedback.
Personally, I've got around this issue with an extension on the deployment builder. Something like this:
(Apologies for code quality, I'm writing on a phone)
However given that farmer bakes-in the location of a resource as part of the add_resources call, you can change the location of the resource group and this won't affect any resource which has already been added.