Cannot create resource with location: 'United States'. Please use location: 'Europe' to create resource for b2b directory:

Paweł Bołdyn 10 Reputation points
2024-12-11T12:14:43.5733333+00:00

Hey!
I'm trying to link a tenant to my subscription. When I try, I receive this error:
Cannot create resource with location: 'United States'. Please use location: 'Europe' to create resource for b2b directory: 'mytenat'

The subscription is in my directory (I'm the owner).
The resource group is created in West Europe.
The tenant is in the European Union.

User's image

Microsoft Security | Microsoft Entra | Microsoft Entra External ID
Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} vote

1 answer

Sort by: Most helpful
  1. Paweł Bołdyn 10 Reputation points
    2024-12-18T14:02:09.6666667+00:00

    It seems like when using the Azure Portal web site, the region will be set as “United State” by default.

    Connect-AzAccount
    $token = (Get-AzAccessToken).Token
    $uri = "https://management.azure.com/subscriptions/{SUBSCRIPTIONID}/resourceGroups/{RESOURCEGROUP}/providers/Microsoft.AzureActiveDirectory/guestUsages/{TENANTNAME}.onmicrosoft.com?api-version=2020-05-01-preview"
    
    $body = @{
        id         = "/subscriptions/{SUBSCRIPTIONID}/resourceGroups/{RESOURCEGROUP}/providers/Microsoft.AzureActiveDirectory/guestUsages/{TENANTNAME}.onmicrosoft.com"
        name       = "{TENANTNAME}.onmicrosoft.com"
        location   = "Europe"
        tags       = @{}
        type       = "Microsoft.AzureActiveDirectory/GuestUsages"
        properties = @{
            tenantId = "{TENANTID}"
        }
    }
    
    $headers = @{
        Authorization = "Bearer $Bearer"
    }
    
    Invoke-RestMethod -Uri $uri -Method Put -Body ($body | ConvertTo-Json -Depth 10) -ContentType "application/json" -Headers $headers
    
    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.