equinor / sepes-api

A platform that allows vendors to prove their solutions on your data.
MIT License
6 stars 2 forks source link

feat: dynamically get supported locations for resource types #842

Open bonyfusbouvet opened 2 years ago

bonyfusbouvet commented 2 years ago

Application should dynamically get supported locations for resource types.

Example PowerShell script for getting all supported locations in Norway and Europe for a resource type:

# Get-AzResourceTypeLocations.ps1

param (
  [string]$ProviderNamespace,
  [string]$ResourceTypeName
)
$Provider = Get-AzResourceProvider -ProviderNamespace $ProviderNamespace
$ResourceType = $Provider.ResourceTypes | Where-Object { $_.ResourceTypeName -eq $ResourceTypeName }
$Locations = $ResourceType.Locations | Where-Object { $_ -like '* Europe' -or $_ -like 'Norway *' }
Write-Output $Locations

Checking supported locations for Storage Accounts:

.\Get-AzResourceTypeLocations.ps1 -ProviderNamespace 'Microsoft.Storage' -ResourceTypeName 'storageAccounts' Outputs:

West Europe North Europe Norway East Checking supported locations for Virtual Machines:

.\Get-AzResourceTypeLocations.ps1 -ProviderNamespace 'Microsoft.Compute' -ResourceTypeName 'virtualMachines' Outputs:

North Europe West Europe Norway East

bonyfusbouvet commented 2 years ago

Query secondary location: https://larry.claman.net/post/2020-04-09-querying-for-azure-regional-pairs/

einaren commented 2 years ago

@bonyfusbouvet is this in prod?