/// <summary> /// Try to get the uri from the environment mathcing the given name /// </summary> /// <param name="environment">The environment to get the value from</param> /// <param name="endpointName">The name of the endpoint to attempt to get</param> /// <param name="endpoint">The returned endpoint value as a Uri, or null if no endpoint was found</param> /// <returns>true if the endpoint was found, otherwise false</returns> public static bool TryGetEndpointUrl(this IAzureEnvironment environment, string endpointName, out Uri endpoint) { bool result = true; endpoint = null; switch (endpointName) { case AzureEnvironment.Endpoint.ActiveDirectory: endpoint = new Uri(environment.ActiveDirectoryAuthority); break; case AzureEnvironment.Endpoint.Gallery: endpoint = new Uri(environment.GalleryUrl); break; case AzureEnvironment.Endpoint.Graph: endpoint = new Uri(environment.GraphUrl); break; case AzureEnvironment.Endpoint.ManagementPortalUrl: endpoint = new Uri(environment.ManagementPortalUrl); break; case AzureEnvironment.Endpoint.PublishSettingsFileUrl: endpoint = new Uri(environment.PublishSettingsFileUrl); break; case AzureEnvironment.Endpoint.ResourceManager: endpoint = new Uri(environment.ResourceManagerUrl); break; case AzureEnvironment.Endpoint.ServiceManagement: endpoint = new Uri(environment.ServiceManagementUrl); break; case AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId: endpoint = new Uri(environment.ActiveDirectoryServiceEndpointResourceId); break; case AzureEnvironment.Endpoint.GraphEndpointResourceId: endpoint = new Uri(environment.GraphEndpointResourceId); break; case AzureEnvironment.Endpoint.DataLakeEndpointResourceId: endpoint = new Uri(environment.DataLakeEndpointResourceId); break; case AzureEnvironment.Endpoint.BatchEndpointResourceId: endpoint = new Uri(environment.BatchEndpointResourceId); break; default: result = environment.IsPropertySet(endpointName); if (result) { endpoint = new Uri(environment.GetProperty(endpointName)); } break; } return(result); }
/// <summary> /// Get non-endpoint values of the environment, such as resource strings and dns suffixes for servides. /// </summary> /// <param name="environment">The environment to check for the given property</param> /// <param name="endpointName">The name of the property to check for</param> /// <param name="propertyValue">The value of the property, if found in the environment, or null if not found</param> /// <returns>True if the property value is found in the environment, otherwise false.</returns> public static bool TryGetEndpointString(this IAzureEnvironment environment, string endpointName, out string propertyValue) { propertyValue = null; if (environment != null) { switch (endpointName) { case AzureEnvironment.Endpoint.AdTenant: propertyValue = environment.AdTenant; break; case AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId: propertyValue = environment.ActiveDirectoryServiceEndpointResourceId; break; case AzureEnvironment.Endpoint.AzureKeyVaultDnsSuffix: propertyValue = environment.AzureKeyVaultDnsSuffix; break; case AzureEnvironment.Endpoint.AzureKeyVaultServiceEndpointResourceId: propertyValue = environment.AzureKeyVaultServiceEndpointResourceId; break; case AzureEnvironment.Endpoint.GraphEndpointResourceId: propertyValue = environment.GraphEndpointResourceId; break; case AzureEnvironment.Endpoint.SqlDatabaseDnsSuffix: propertyValue = environment.SqlDatabaseDnsSuffix; break; case AzureEnvironment.Endpoint.StorageEndpointSuffix: propertyValue = environment.StorageEndpointSuffix; break; case AzureEnvironment.Endpoint.TrafficManagerDnsSuffix: propertyValue = environment.TrafficManagerDnsSuffix; break; case AzureEnvironment.Endpoint.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix: propertyValue = environment.AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix; break; case AzureEnvironment.Endpoint.AzureDataLakeStoreFileSystemEndpointSuffix: propertyValue = environment.AzureDataLakeStoreFileSystemEndpointSuffix; break; case AzureEnvironment.Endpoint.DataLakeEndpointResourceId: propertyValue = environment.DataLakeEndpointResourceId; break; case AzureEnvironment.Endpoint.ActiveDirectory: propertyValue = environment.ActiveDirectoryAuthority; break; case AzureEnvironment.Endpoint.Gallery: propertyValue = environment.GalleryUrl; break; case AzureEnvironment.Endpoint.Graph: propertyValue = environment.GraphUrl; break; case AzureEnvironment.Endpoint.ManagementPortalUrl: propertyValue = environment.ManagementPortalUrl; break; case AzureEnvironment.Endpoint.PublishSettingsFileUrl: propertyValue = environment.PublishSettingsFileUrl; break; case AzureEnvironment.Endpoint.ResourceManager: propertyValue = environment.ResourceManagerUrl; break; case AzureEnvironment.Endpoint.ServiceManagement: propertyValue = environment.ServiceManagementUrl; break; case AzureEnvironment.Endpoint.BatchEndpointResourceId: propertyValue = environment.BatchEndpointResourceId; break; default: // get property from the extended properties of the environment propertyValue = environment.GetProperty(endpointName); break; } } return(propertyValue != null); }