When you create an instance in dataverse you get to choose which region it is located in. However, you do not get to choose which exact datacenter you get. How is this important? Well, if you want to mirror data using Azure Synapse Link or Microsoft Fabric, then these resources have to be in the exact same datacenter to work. If you have several instances, there is a risk that some are in one of the datacenters in the region and some in the other. For instance, in the region Europe, there are two datacenters, North Europe (Dublin) and West Europe (Amsterdam). So, it might very well be that some instances are in Dublin and some in Amsterdam.

Currently there is only one way to move an instance, and that is to create a ticket and ask Microsoft Support to do it for you. But you first need to know where it is.

The easiest way to find where you instance is located, is actually to start the wizard for synchronizing data to a datalake using Azure Synapse Link from the Maker-portal. It should look something like this:

However, if you have many instances, you might want to have a script that outputs this. Well, I did anyway, so I was looking into how to do this using Powershell.

Hence I dug into some of the PowerShell libraries for Power Platform and created this PowerShell script:

# Get all environments
$environments = Get-AdminPowerAppEnvironment

# Loop through each environment and output DisplayName and azureRegionHint to a file
$environments | ForEach-Object {
    # Create a custom object with the properties you want
    [PSCustomObject]@{
        DisplayName = $_.DisplayName
        Type = $_.EnvironmentType
        azureRegionHint = $_.Internal.properties.azureRegionHint
    }
} | Export-Csv -Path "C:\temp\output.csv" -NoTypeInformation

In this case the “azureRegionHint” was supposed to show the right datacenter. But that turned out to be a half-truth as many of the instances were correct but not all. I suspect it might be stored list and not the actual list, as at least one of the ones that were incorrect has been moved.

I reported this to Microsoft support, as my view is that the azureRegionHint should display the correct datacenter, and hence what I experienced is a bug. But I never got this acknowledged by support who instead recommended that I use “ping” to figure out the region;

C:\Users\GustafWesterlund>ping xxx.crm4.dynamics.com

Pinging db3--eurcrmlivesg000.crm4.dynamics.com [52.155.235.153] with 32 bytes of data:
Reply from 52.155.235.153: bytes=32 time=56ms TTL=107
Reply from 52.155.235.153: bytes=32 time=55ms TTL=107
Reply from 52.155.235.153: bytes=32 time=69ms TTL=107
Reply from 52.155.235.153: bytes=32 time=75ms TTL=107

Ping statistics for 52.155.235.153:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 55ms, Maximum = 75ms, Average = 63ms

In the response above, db is “Dublin” and my guess is that the “3” means datacenter 3 or something like that.

However, using ping to do what in essence is a nslookup didn’t seem very useful and I also wanted to be able to use PowerShell, so I looked up the command:

Resolve-DnsName -Name $url

This is in essence nslookup, which, if you are not very versed in this, will give you the IP address and official name of a specific alias (cname). As the following example shows:

PS C:\WINDOWS\system32> Resolve-DnsName -Name xxx.crm4.dynamics.com

Name                           Type   TTL   Section    NameHost                                                                                                                               
----                           ----   ---   -------    --------                                                                                                                               
xxx.crm4.dynamics.com     CNAME  300   Answer     db3--eurcrmlivesg000.crm4.dynamics.com                                                                                                 

Name       : db3--eurcrmlivesg000.crm4.dynamics.com
QueryType  : AAAA
TTL        : 300
Section    : Answer
IP6Address : 2603:1061:2002:968::36


Name       : db3--eurcrmlivesg000.crm4.dynamics.com
QueryType  : A
TTL        : 300
Section    : Answer
IP4Address : 52.155.235.153

The first part is the information that the DNS entry is a cname/alias to the aname which starts with db3. The following two blocks are the IPs in IP v6 and IP v4 of this name. Using this I adapted my script and added a manual switch which shows the datacenter which starts with “ams” as West Europe and “db3” as North Europe. Don’t know if this information is available anywhere so that I can look it up instead as that would be a lot more dynamic. But at least I can loop through all instances and get the azure datacenter for each of the instances. Here is the script:

$connectionhost = "https://admin.services.crm4.dynamics.com"
$output = New-Object System.Collections.Generic.List[System.Object]
foreach ($inst in Get-CrmInstances -ApiUrl $connectionhost | Select-Object -Property FriendlyName, ApplicationUrl)
{
    $url = $inst.ApplicationUrl.Substring(8,$inst.ApplicationUrl.Length - 9)
    
    $dns = Resolve-DnsName -Name $url
    $center = ""
    switch($dns[1].Name.Substring(0,3)) {
    "ams" {
        $center = "West Europe" }
    "db3" {
        $center = "North Europe" }
    }

    $out = [PSCustomObject]@{
        Name = $inst.FriendlyName
        url = $dns[1].Name
        AzCenter = $center
    }

    $output.Add($out)
}
$output | Format-Table -Property Name, AzCenter, url

I hope and guess there are easier ways to solve this. If you have any ideas, please let me know in the comments or if you have any other method to solve this for a lot of instances where using the UI would be a bit too much of a hassle.

Hope it helps!