public static Uri GetStorageBlobContainerUri(string containerName, Runtime.Common.DataAccess.ConnectionStrings.StorageAccountConnectionString sacs)
        {
            //check if KeyType = SAS and change URL...

            Uri uri = new Uri(new Uri(sacs.AccountEndpoint), containerName);

            if (sacs.KeyType == Runtime.Common.DataAccess.ConnectionStrings.StorageAccountConnectionString.AccountKeyType.SAS)
            {
                //todo: add sas query string
            }

            return(uri);
        }
        private async Task <string> GenerateKey(Secret secret, string newKeyName, CancellationToken token)
        {
            Runtime.Common.DataAccess.ConnectionStrings.StorageAccountConnectionString sacs = new Runtime.Common.DataAccess.ConnectionStrings.StorageAccountConnectionString()
            {
                ConnectionString = secret.Configuration.SourceConnectionString
            };

            var azure = GetAzureEnvironment();

            string accountId = $"/subscriptions/{secret.Configuration.SubscriptionId}/resourceGroups/{sacs.ResourceGroup}/providers/Microsoft.Storage/storageAccounts/{sacs.AccountName}";

            var account = await azure.StorageAccounts.GetByIdAsync(accountId, token);

            //if (string.IsNullOrWhiteSpace(secret.CurrentKeyName)) secret.CurrentKeyName = ValidKeyNames.Key1;

            var keys = await account.RegenerateKeyAsync(newKeyName, token);

            foreach (var key in keys)
            {
                if (string.Compare(key.KeyName, newKeyName, true) == 0)
                {
                    return(key.Value);
                }
            }

            return(null);
        }
        public static Azure.Storage.Blobs.BlobContainerClient CreateBlobContainerClient(Runtime.Common.Configuration.IConfigurationManager config, string containerName)
        {
            Runtime.Common.DataAccess.ConnectionStrings.StorageAccountConnectionString sacs = config.SecretManagementConnectionString.CommandConnectionString;

            string cacheKey = $"connection={sacs.ConnectionString.ToLower()};queue={containerName}";

            if (_clientCache.ContainsKey(cacheKey))
            {
                return(_clientCache[cacheKey]);
            }

            Uri uri = GetStorageBlobContainerUri(containerName, sacs);

            switch (sacs.KeyType)
            {
            case Runtime.Common.DataAccess.ConnectionStrings.StorageAccountConnectionString.AccountKeyType.None:
                return(EnsureClientCache(cacheKey, new Azure.Storage.Blobs.BlobContainerClient(uri, new DefaultAzureCredential())));

            case Runtime.Common.DataAccess.ConnectionStrings.StorageAccountConnectionString.AccountKeyType.SAS:
                return(EnsureClientCache(cacheKey, new Azure.Storage.Blobs.BlobContainerClient(uri)));

            case Runtime.Common.DataAccess.ConnectionStrings.StorageAccountConnectionString.AccountKeyType.AccountKey:
                return(EnsureClientCache(cacheKey, new Azure.Storage.Blobs.BlobContainerClient(sacs.ToStorageAccountFormat(), containerName)));
            }

            return(null);
        }