/// <summary> /// Get the default resource group for stoarge admin. /// This is consturcted as "System." + Location /// </summary> protected void GetDefaultResourceGroup() { WriteVerbose("Fetching default Resource Group"); ResourceManagerSdkClient resourcesSdkClient = new ResourceManagerSdkClient(DefaultContext) { VerboseLogger = WriteVerboseWithTimestamp, ErrorLogger = WriteErrorWithTimestamp, WarningLogger = WriteWarningWithTimestamp }; PSResourceProvider[] providers = resourcesSdkClient.ListResourceProviders(providerName: AzureStackStorageAdminNameSpace) .Select(provider => provider.ToPSResourceProvider()).ToArray(); if (null == providers || null == providers.FirstOrDefault() || null == providers.FirstOrDefault().Locations || String.IsNullOrEmpty(providers.FirstOrDefault().Locations.FirstOrDefault())) { WriteErrorWithTimestamp(String.Format("Failed to get Resource Provider {0}", AzureStackStorageAdminNameSpace)); WriteErrorWithTimestamp("Failed to Obtain Default location"); throw new InvalidOperationException("Failed to Obtain Default location"); } else { this.ResourceGroupName = AzureStackStorageAdminDefaultResourceGroupPrefix + providers.First().Locations.First(); WriteVerbose(String.Format("Obtained Default Resource Group {0}", this.ResourceGroupName)); } }