示例#1
0
        /// <summary>
        /// If the storage account already exists (have to be globally unique) - none will be created. Exceptions are handled.
        /// </summary>
        /// <param name="storageClient">The StorageClient that mapps our subscription.</param>
        /// <param name="storageAccountName">The Storage Account we want to create.</param>
        /// <param name="location">The location where we want the storage account.</param>
        /// <returns>True if the storage account was created or already exists. False if it could not be created.</returns>
        public static bool TryCreateNewStorageAccount(this IStorageClient storageClient, string storageAccountName, string location = LocationConstants.NorthEurope)
        {
            try
            {
                storageClient.CreateNewStorageAccountIfNotExists(storageAccountName, location);
            }
            catch (WebException)
            {
                return(false);
            }
            catch (InvalidOperationException)
            {
                return(false);
            }

            return(true);
        }