Hello Roy_Jaze,
Greetings! Welcome to Microsoft Q&A Platform.
You can retrieve a list of all Azure regions using the Azure Management Libraries for .NET. Here’s a sample C# code snippet that demonstrates how to do this:
using System;
using System.Threading.Tasks;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Resources;
class Program
{
static async Task Main(string[] args)
{
var credential = new DefaultAzureCredential();
var armClient = new ArmClient(credential);
var subscription = await armClient.GetDefaultSubscriptionAsync();
var locations = subscription.GetLocationsAsync();
await foreach (var location in locations)
{
Console.WriteLine(location.DisplayName);
}
}
}
This code uses the Azure.Identity
and Azure.ResourceManager
libraries to authenticate and list all available regions for your subscription. Make sure you have the necessary NuGet packages installed:
dotnet add package Azure.Identity
dotnet add package Azure.ResourceManager
This approach is more efficient and reliable than creating a storage account in an unavailable location and catching exceptions.
Note: The above is an example code - Please modify per your requirements.
Similar thread for reference - https://stackoverflow.com/questions/44143981/is-there-an-api-to-list-all-azure-regions, https://github.com/Azure-Samples/storage-dotnet-resource-provider-getting-started, https://video2.skills-academy.com/en-us/samples/azure-samples/storage-dotnet-resource-provider-getting-started/storage-dotnet-resource-provider-getting-started/
This link provides detailed information of regions availability and also product by region
https://azure.microsoft.com/en-in/global-infrastructure/services/?products=storage®ions=all.
Hope this information helps! Please let us know if you have any further queries. I’m happy to assist you further.
Please "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.