public void CanGetStorageAccountName_Production()
        {
            var storageCreds = new WindowsAzureStorageAccountCredentials()
            {
                Name = "demostorage"
            };

            var wabsStorageClient = new WabStorageAbstraction(storageCreds);
            Assert.AreEqual(wabsStorageClient.StorageAccountName, "demostorage");
            Assert.AreEqual(wabsStorageClient.StorageAccountRoot, "http://demostorage.blob.core.windows.net/");
        }
        public void CanGetStorageAccountName_Internal()
        {
            var storageCreds = new WindowsAzureStorageAccountCredentials()
            {
                Name = Constants.WabsProtocolSchemeName + "demostorage.blob.core.windows-int.net"
            };

            var wabsStorageClient = new WabStorageAbstraction(storageCreds);
            Assert.AreEqual("demostorage", wabsStorageClient.StorageAccountName);
            Assert.AreEqual("http://demostorage.blob.core.windows-int.net", wabsStorageClient.StorageAccountRoot);
        }
        public static async Task ValidateAndResolveWasbScriptActionEndpointUri(Uri uri, WabStorageAccountConfiguration storage)
        {
            if (uri == null)
            {
                throw new ArgumentNullException("uri");
            }

            if (storage == null)
            {
                throw new ArgumentNullException("storage");
            }

            // Try to check the existence of the script in the URI specified.
            var storageAbstractionCreds = new WindowsAzureStorageAccountCredentials()
            {
                Key = storage.Key,
                Name = GetFullyQualifiedStorageAccountName(storage.Name),
            };

            var storageAbstraction = new WabStorageAbstraction(storageAbstractionCreds);

            bool exists = false;

            try
            {
                // Firstly converts the URI to wasb style and then test it against wasb storage for existence.
                exists = await storageAbstraction.Exists(ConvertToWasbUriIfNeeded(uri));
            }
            catch (Exception e)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Script action URI: {0} cannot be retrieved correctly. Inner exception: {1}", uri.AbsoluteUri, e.Message), e);
            }

            if (!exists)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Script action URI: {0} cannot be retrieved correctly because it does not exist", uri.AbsoluteUri));
            }
        }