Exemple #1
0
        /// <summary>
        /// Lists all available geo-locations.
        /// </summary>
        /// <param name="resourceType"> The <see cref="ResourceType"/> instance to use for the list. </param>
        /// <param name="cancellationToken"> A token to allow the caller to cancel the call to the service. The default value is <see cref="CancellationToken.None" />. </param>
        /// <returns> A collection of location that may take multiple service requests to iterate over. </returns>
        protected IEnumerable <AzureLocation> ListAvailableLocations(ResourceType resourceType, CancellationToken cancellationToken = default)
        {
            ProviderInfo resourcePageableProvider = ArmClient.GetTenantProvider(resourceType.Namespace, null, cancellationToken);

            if (resourcePageableProvider is null)
            {
                throw new InvalidOperationException($"{resourceType.Type} not found for {resourceType.Namespace}");
            }
            var theResource = resourcePageableProvider.ResourceTypes.FirstOrDefault(r => resourceType.Type.Equals(r.ResourceType, StringComparison.Ordinal));

            if (theResource is null)
            {
                throw new InvalidOperationException($"{resourceType.Type} not found for {resourceType.Type}");
            }
            return(theResource.Locations.Select(l => new AzureLocation(l)));
        }