public async Task createStorageAccountAndGetFileShareCollection()
        {
            ArmClient    armClient    = new ArmClient(new DefaultAzureCredential());
            Subscription subscription = await armClient.GetDefaultSubscriptionAsync();

            string        rgName   = "myRgName";
            AzureLocation location = AzureLocation.WestUS2;
            ArmOperation <ResourceGroup> operation = await subscription.GetResourceGroups().CreateOrUpdateAsync(true, rgName, new ResourceGroupData(location));

            ResourceGroup resourceGroup = operation.Value;

            this.resourceGroup = resourceGroup;
            Sku    sku         = new Sku(SkuName.StandardGRS);
            Kind   kind        = Kind.Storage;
            string locationStr = "westus2";
            StorageAccountCreateParameters parameters        = new StorageAccountCreateParameters(sku, kind, locationStr);
            StorageAccountCollection       accountCollection = resourceGroup.GetStorageAccounts();
            string accountName = "myAccount";
            ArmOperation <StorageAccount> accountCreateOperation = await accountCollection.CreateOrUpdateAsync(false, accountName, parameters);

            storageAccount = await accountCreateOperation.WaitForCompletionAsync();

            #region Snippet:Managing_FileShares_GetFileService
            FileService fileService = await storageAccount.GetFileService().GetAsync();

            #endregion
            this.fileService = fileService;
        }
Ejemplo n.º 2
0
        public async Task UpdateAccountIdentityFromNoneToSystem()
        {
            _resourceGroup = await CreateResourceGroupAsync();

            StorageAccountCollection storageAccountCollection = _resourceGroup.GetStorageAccounts();

            string accountName = await CreateValidAccountNameAsync(namePrefix);

            var            param    = GetDefaultStorageAccountParameters(sku: new StorageSku(StorageSkuName.StandardLRS));
            StorageAccount account1 = (await storageAccountCollection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, param)).Value;

            Assert.AreEqual(accountName, account1.Id.Name);
            VerifyAccountProperties(account1, false);
            Assert.Null(account1.Data.Identity);

            PatchableStorageAccountData parameters = new PatchableStorageAccountData()
            {
                Identity = new ManagedServiceIdentity(ManagedServiceIdentityType.SystemAssigned)
            };

            account1 = await account1.UpdateAsync(parameters);

            Assert.AreEqual(ManagedServiceIdentityType.SystemAssigned, account1.Data.Identity.ManagedServiceIdentityType);
            Assert.IsEmpty(account1.Data.Identity.UserAssignedIdentities);
            Assert.NotNull(account1.Data.Identity.PrincipalId);
            Assert.NotNull(account1.Data.Identity.TenantId);

            // validate
            StorageAccount account2 = await storageAccountCollection.GetAsync(accountName);

            Assert.AreEqual(ManagedServiceIdentityType.SystemAssigned, account2.Data.Identity.ManagedServiceIdentityType);
            Assert.IsEmpty(account2.Data.Identity.UserAssignedIdentities);
            Assert.NotNull(account2.Data.Identity.PrincipalId);
            Assert.NotNull(account2.Data.Identity.TenantId);
        }
Ejemplo n.º 3
0
        public async Task createStorageAccountAndGetBlobContainerCollection()
        {
            ArmClient            armClient    = new ArmClient(new DefaultAzureCredential());
            SubscriptionResource subscription = await armClient.GetDefaultSubscriptionAsync();

            string        rgName   = "myRgName";
            AzureLocation location = AzureLocation.WestUS2;
            ArmOperation <ResourceGroupResource> operation = await subscription.GetResourceGroups().CreateOrUpdateAsync(WaitUntil.Completed, rgName, new ResourceGroupData(location));

            ResourceGroupResource resourceGroup = operation.Value;

            this.resourceGroup = resourceGroup;
            StorageSku  sku         = new StorageSku(StorageSkuName.StandardGRS);
            StorageKind kind        = StorageKind.Storage;
            string      locationStr = "westus2";
            StorageAccountCreateParameters parameters        = new StorageAccountCreateParameters(sku, kind, locationStr);
            StorageAccountCollection       accountCollection = resourceGroup.GetStorageAccounts();
            string accountName = "myAccount";
            ArmOperation <StorageAccountResource> accountCreateOperation = await accountCollection.CreateOrUpdateAsync(WaitUntil.Started, accountName, parameters);

            storageAccount = await accountCreateOperation.WaitForCompletionAsync();

            #region Snippet:Managing_BlobContainers_GetBlobService
            BlobServiceResource blobService = storageAccount.GetBlobService();
            #endregion
            this.blobService = blobService;
        }
        public async Task Get()
        {
            #region Snippet:Managing_StorageAccounts_GetStorageAccount
            StorageAccountCollection accountCollection = resourceGroup.GetStorageAccounts();
            StorageAccount           storageAccount    = await accountCollection.GetAsync("myAccount");

            Console.WriteLine(storageAccount.Id.Name);
            #endregion
        }
        public async Task Delete()
        {
            #region Snippet:Managing_StorageAccounts_DeleteStorageAccount
            StorageAccountCollection accountCollection = resourceGroup.GetStorageAccounts();
            StorageAccount           storageAccount    = await accountCollection.GetAsync("myAccount");

            await storageAccount.DeleteAsync();

            #endregion
        }
 public async Task list()
 {
     #region Snippet:Managing_StorageAccounts_ListStorageAccounts
     StorageAccountCollection       accountCollection = resourceGroup.GetStorageAccounts();
     AsyncPageable <StorageAccount> response          = accountCollection.GetAllAsync();
     await foreach (StorageAccount storageAccount in response)
     {
         Console.WriteLine(storageAccount.Id.Name);
     }
     #endregion
 }
        public async Task AddTag()
        {
            #region Snippet:Managing_StorageAccounts_AddTagStorageAccount
            StorageAccountCollection accountCollection = resourceGroup.GetStorageAccounts();
            StorageAccount           storageAccount    = await accountCollection.GetAsync("myAccount");

            // add a tag on this storage account
            await storageAccount.AddTagAsync("key", "value");

            #endregion
        }
 public async Task ClearStorageAccount()
 {
     if (_resourceGroup != null)
     {
         StorageAccountCollection storageAccountCollection = _resourceGroup.GetStorageAccounts();
         await foreach (StorageAccountResource account in storageAccountCollection.GetAllAsync())
         {
             await account.DeleteAsync(WaitUntil.Completed);
         }
         _resourceGroup  = null;
         _storageAccount = null;
     }
 }
        public async Task createStorageAccountAndGetBlobContainerContainer()
        {
            _resourceGroup = await CreateResourceGroupAsync();

            string accountName = await CreateValidAccountNameAsync("teststoragemgmt");

            StorageAccountCollection storageAccountCollection = _resourceGroup.GetStorageAccounts();

            _storageAccount = (await storageAccountCollection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, GetDefaultStorageAccountParameters())).Value;
            _blobService    = _storageAccount.GetBlobService();
            _blobService    = await _blobService.GetAsync();

            _blobContainerCollection = _blobService.GetBlobContainers();
        }
Ejemplo n.º 10
0
        public async Task CreateStorageAccountAndGetTableCollection()
        {
            _resourceGroup = await CreateResourceGroupAsync();

            string accountName = await CreateValidAccountNameAsync("teststoragemgmt");

            StorageAccountCollection storageAccountCollection = _resourceGroup.GetStorageAccounts();

            _storageAccount = (await storageAccountCollection.CreateOrUpdateAsync(accountName, GetDefaultStorageAccountParameters())).Value;
            _tableService   = _storageAccount.GetTableService();
            _tableService   = await _tableService.GetAsync();

            _tableCollection = _tableService.GetTables();
        }
Ejemplo n.º 11
0
        public async Task UpdateAccountIdentityFromTwoUsersToOneUser()
        {
            _resourceGroup = await CreateResourceGroupAsync();

            StorageAccountCollection storageAccountCollection = _resourceGroup.GetStorageAccounts();

            string accountName = await CreateValidAccountNameAsync(namePrefix);

            var identity = new ManagedServiceIdentity(ManagedServiceIdentityType.UserAssigned);
            var userAssignedIdentity1 = await CreateUserAssignedIdentityAsync();

            identity.UserAssignedIdentities.Add(userAssignedIdentity1.Id, new UserAssignedIdentity());
            var userAssignedIdentity2 = await CreateUserAssignedIdentityAsync();

            identity.UserAssignedIdentities.Add(userAssignedIdentity2.Id, new UserAssignedIdentity());
            var            param    = GetDefaultStorageAccountParameters(sku: new StorageSku(StorageSkuName.StandardLRS), identity: identity);
            StorageAccount account1 = (await storageAccountCollection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, param)).Value;

            Assert.AreEqual(accountName, account1.Id.Name);
            VerifyAccountProperties(account1, false);
            Assert.AreEqual(ManagedServiceIdentityType.UserAssigned, account1.Data.Identity.ManagedServiceIdentityType);
            Assert.AreEqual(account1.Data.Identity.UserAssignedIdentities.Count, 2);
            Assert.Null(account1.Data.Identity.PrincipalId);
            Assert.NotNull(account1.Data.Identity.UserAssignedIdentities[userAssignedIdentity1.Id].PrincipalId);
            Assert.NotNull(account1.Data.Identity.UserAssignedIdentities[userAssignedIdentity2.Id].PrincipalId);

            account1.Data.Identity.UserAssignedIdentities[userAssignedIdentity1.Id] = null;
            PatchableStorageAccountData parameters = new PatchableStorageAccountData()
            {
                Identity = account1.Data.Identity
            };

            account1 = await account1.UpdateAsync(parameters);

            Assert.AreEqual(ManagedServiceIdentityType.UserAssigned, account1.Data.Identity.ManagedServiceIdentityType);
            Assert.AreEqual(account1.Data.Identity.UserAssignedIdentities.Count, 1);
            Assert.Null(account1.Data.Identity.PrincipalId);
            Assert.Null(account1.Data.Identity.UserAssignedIdentities[userAssignedIdentity1.Id]);
            Assert.NotNull(account1.Data.Identity.UserAssignedIdentities[userAssignedIdentity2.Id].PrincipalId);

            // validate
            StorageAccount account2 = await storageAccountCollection.GetAsync(accountName);

            Assert.AreEqual(ManagedServiceIdentityType.UserAssigned, account1.Data.Identity.ManagedServiceIdentityType);
            Assert.AreEqual(account1.Data.Identity.UserAssignedIdentities.Count, 1);
            Assert.Null(account1.Data.Identity.PrincipalId);
            Assert.IsFalse(account1.Data.Identity.UserAssignedIdentities.ContainsKey(userAssignedIdentity1.Id));
            Assert.NotNull(account1.Data.Identity.UserAssignedIdentities[userAssignedIdentity2.Id].PrincipalId);
        }
Ejemplo n.º 12
0
        public async Task UpdateAccountIdentityFromUserToTwoUsers()
        {
            _resourceGroup = await CreateResourceGroupAsync();

            StorageAccountCollection storageAccountCollection = _resourceGroup.GetStorageAccounts();

            string accountName = await CreateValidAccountNameAsync(namePrefix);

            var identity             = new ManagedServiceIdentity(ManagedServiceIdentityType.UserAssigned);
            var userAssignedIdentity = await CreateUserAssignedIdentityAsync();

            identity.UserAssignedIdentities.Add(userAssignedIdentity.Id, new UserAssignedIdentity());
            var            param    = GetDefaultStorageAccountParameters(sku: new StorageSku(StorageSkuName.StandardLRS), identity: identity);
            StorageAccount account1 = (await storageAccountCollection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, param)).Value;

            Assert.AreEqual(accountName, account1.Id.Name);
            VerifyAccountProperties(account1, false);
            Assert.AreEqual(ManagedServiceIdentityType.UserAssigned, account1.Data.Identity.ManagedServiceIdentityType);
            Assert.AreEqual(account1.Data.Identity.UserAssignedIdentities.Count, 1);
            Assert.Null(account1.Data.Identity.PrincipalId);
            Assert.NotNull(account1.Data.Identity.UserAssignedIdentities[userAssignedIdentity.Id].PrincipalId);

            // With JSON Merge Patch, we only need to put the identity to add in the dictionary for update operation.
            var identity2             = new ManagedServiceIdentity(ManagedServiceIdentityType.UserAssigned);
            var userAssignedIdentity2 = await CreateUserAssignedIdentityAsync();

            identity2.UserAssignedIdentities.Add(userAssignedIdentity2.Id, new UserAssignedIdentity());
            PatchableStorageAccountData parameters = new PatchableStorageAccountData()
            {
                Identity = identity2
            };

            account1 = await account1.UpdateAsync(parameters);

            Assert.AreEqual(ManagedServiceIdentityType.UserAssigned, account1.Data.Identity.ManagedServiceIdentityType);
            Assert.AreEqual(account1.Data.Identity.UserAssignedIdentities.Count, 2);
            Assert.Null(account1.Data.Identity.PrincipalId);
            Assert.NotNull(account1.Data.Identity.UserAssignedIdentities[userAssignedIdentity.Id].PrincipalId);
            Assert.NotNull(account1.Data.Identity.UserAssignedIdentities[userAssignedIdentity2.Id].PrincipalId);

            // validate
            StorageAccount account2 = await storageAccountCollection.GetAsync(accountName);

            Assert.AreEqual(ManagedServiceIdentityType.UserAssigned, account2.Data.Identity.ManagedServiceIdentityType);
            Assert.AreEqual(account2.Data.Identity.UserAssignedIdentities.Count, 2);
            Assert.Null(account2.Data.Identity.PrincipalId);
            Assert.NotNull(account2.Data.Identity.UserAssignedIdentities[userAssignedIdentity.Id].PrincipalId);
            Assert.NotNull(account2.Data.Identity.UserAssignedIdentities[userAssignedIdentity2.Id].PrincipalId);
        }
Ejemplo n.º 13
0
        public void CreateStorageAccount()
        {
#endif
string accountName = "myaccount";
string resourceGroupName = "myResourceGroup";
ArmClient client = new ArmClient(new DefaultAzureCredential());
ResourceGroupResource resourceGroup = client.GetDefaultSubscription().GetResourceGroups().Get(resourceGroupName);
StorageAccountCollection storageAccountCollection = resourceGroup.GetStorageAccounts();
StorageSku sku = new StorageSku(StorageSkuName.PremiumLRS);
StorageAccountCreateOrUpdateContent parameters = new StorageAccountCreateOrUpdateContent(new StorageSku(StorageSkuName.StandardGRS), StorageKind.Storage, AzureLocation.WestUS);
parameters.Tags.Add("key1", "value1");
parameters.Tags.Add("key2", "value2");
StorageAccountResource account = storageAccountCollection.CreateOrUpdate(WaitUntil.Completed, accountName, parameters).Value;
            #endregion
        }
Ejemplo n.º 14
0
        public async Task ClearStorageAccounts()
        {
            //remove all storage accounts under current resource group
            if (_resourceGroup != null)
            {
                StorageAccountCollection storageAccountCollection = _resourceGroup.GetStorageAccounts();
                List <StorageAccount>    storageAccountList       = await storageAccountCollection.GetAllAsync().ToEnumerableAsync();

                foreach (StorageAccount account in storageAccountList)
                {
                    await account.DeleteAsync(WaitUntil.Completed);
                }
                _resourceGroup = null;
            }
        }
        public async Task CreateOrUpdate()
        {
            #region Snippet:Managing_StorageAccounts_CreateStorageAccount
            //first we need to define the StorageAccountCreateParameters
            Sku    sku      = new Sku(SkuName.StandardGRS);
            Kind   kind     = Kind.Storage;
            string location = "westus2";
            StorageAccountCreateParameters parameters = new StorageAccountCreateParameters(sku, kind, location);
            //now we can create a storage account with defined account name and parameters
            StorageAccountCollection accountCollection = resourceGroup.GetStorageAccounts();
            string accountName = "myAccount";
            StorageAccountCreateOperation accountCreateOperation = await accountCollection.CreateOrUpdateAsync(accountName, parameters);

            StorageAccount storageAccount = accountCreateOperation.Value;
            #endregion
        }
        public async Task GetIfExist()
        {
            #region Snippet:Managing_StorageAccounts_GetStorageAccountIfExists
            StorageAccountCollection accountCollection = resourceGroup.GetStorageAccounts();
            StorageAccount           storageAccount    = await accountCollection.GetIfExistsAsync("foo");

            if (storageAccount != null)
            {
                Console.WriteLine(storageAccount.Id.Name);
            }
            if (await accountCollection.CheckIfExistsAsync("bar"))
            {
                Console.WriteLine("storage account 'bar' exists");
            }
            #endregion
        }
        public async Task UpdateAccountIdentityToRemoveUser()
        {
            _resourceGroup = await CreateResourceGroupAsync();

            StorageAccountCollection storageAccountCollection = _resourceGroup.GetStorageAccounts();

            string accountName = await CreateValidAccountNameAsync(namePrefix);

            var identity             = new ManagedServiceIdentity(ManagedServiceIdentityType.UserAssigned);
            var userAssignedIdentity = await CreateUserAssignedIdentityAsync();

            identity.UserAssignedIdentities.Add(userAssignedIdentity.Id.ToString(), new UserAssignedIdentity());
            var            param    = GetDefaultStorageAccountParameters(sku: new Sku(SkuName.StandardLRS), identity: identity);
            StorageAccount account1 = (await storageAccountCollection.CreateOrUpdateAsync(true, accountName, param)).Value;

            Assert.AreEqual(accountName, account1.Id.Name);
            VerifyAccountProperties(account1, false);
            Assert.AreEqual(ManagedServiceIdentityType.UserAssigned, account1.Data.Identity.Type);
            Assert.Greater(account1.Data.Identity.UserAssignedIdentities.Count, 0);
            Assert.Null(account1.Data.Identity.PrincipalId);
            Assert.NotNull(account1.Data.Identity.UserAssignedIdentities[userAssignedIdentity.Id.ToString()].PrincipalId);

            account1.Data.Identity.UserAssignedIdentities[userAssignedIdentity.Id.ToString()] = null;
            account1.Data.Identity.Type = ManagedServiceIdentityType.None;
            StorageAccountUpdateOptions parameters = new StorageAccountUpdateOptions()
            {
                Identity = account1.Data.Identity
            };

            account1 = await account1.UpdateAsync(parameters);

            Assert.AreEqual(ManagedServiceIdentityType.None, account1.Data.Identity.Type);
            Assert.AreEqual(account1.Data.Identity.UserAssignedIdentities.Count, 0);
            Assert.Null(account1.Data.Identity.PrincipalId);
            Assert.Null(account1.Data.Identity.TenantId);

            // validate
            StorageAccount account2 = await storageAccountCollection.GetAsync(accountName);

            Assert.AreEqual(ManagedServiceIdentityType.None, account2.Data.Identity.Type);
            Assert.AreEqual(account2.Data.Identity.UserAssignedIdentities.Count, 0);
            Assert.Null(account2.Data.Identity.PrincipalId);
            Assert.Null(account2.Data.Identity.TenantId);
        }
        public async Task CreateAccountWithSystemAssignedIdentity()
        {
            _resourceGroup = await CreateResourceGroupAsync();

            StorageAccountCollection storageAccountCollection = _resourceGroup.GetStorageAccounts();

            string accountName = await CreateValidAccountNameAsync(namePrefix);

            var            identity = new ManagedServiceIdentity(ManagedServiceIdentityType.SystemAssigned);
            var            param    = GetDefaultStorageAccountParameters(sku: new Sku(SkuName.StandardLRS), identity: identity);
            StorageAccount account1 = (await storageAccountCollection.CreateOrUpdateAsync(true, accountName, param)).Value;

            Assert.AreEqual(accountName, account1.Id.Name);
            VerifyAccountProperties(account1, false);
            Assert.AreEqual(ManagedServiceIdentityType.SystemAssigned, account1.Data.Identity.Type);
            Assert.IsEmpty(account1.Data.Identity.UserAssignedIdentities);
            Assert.NotNull(account1.Data.Identity.PrincipalId);
            Assert.NotNull(account1.Data.Identity.TenantId);
        }
Ejemplo n.º 19
0
        public async Task CreateAccountWithUserAssignedIdentity()
        {
            _resourceGroup = await CreateResourceGroupAsync();

            StorageAccountCollection storageAccountCollection = _resourceGroup.GetStorageAccounts();

            string accountName = await CreateValidAccountNameAsync(namePrefix);

            var identity             = new ManagedServiceIdentity(ManagedServiceIdentityType.UserAssigned);
            var userAssignedIdentity = await CreateUserAssignedIdentityAsync();

            identity.UserAssignedIdentities.Add(userAssignedIdentity.Id, new UserAssignedIdentity());
            var            param    = GetDefaultStorageAccountParameters(sku: new StorageSku(StorageSkuName.StandardLRS), identity: identity);
            StorageAccount account1 = (await storageAccountCollection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, param)).Value;

            Assert.AreEqual(accountName, account1.Id.Name);
            VerifyAccountProperties(account1, false);
            Assert.AreEqual(ManagedServiceIdentityType.UserAssigned, account1.Data.Identity.ManagedServiceIdentityType);
            Assert.AreEqual(account1.Data.Identity.UserAssignedIdentities.Count, 1);
            Assert.Null(account1.Data.Identity.PrincipalId);
            Assert.NotNull(account1.Data.Identity.UserAssignedIdentities[userAssignedIdentity.Id].PrincipalId);
        }
        public async Task EventCreateGetUpdateDelete()
        {
            var location = await GetLocation();

            var          resourceGroupName = Recording.GenerateAssetName(Helper.ResourceGroupPrefix);
            Subscription sub = await ArmClient.GetDefaultSubscriptionAsync();

            ResourceGroup resourceGroup = (await sub.GetResourceGroups().CreateOrUpdateAsync(resourceGroupName, new ResourceGroupData(location))).Value;

            // Prepare Storage Account
            var accountName = Recording.GenerateAssetName("sdktestaccount");
            var storageAccountCreateParameters = new StorageAccountCreateParameters(
                new ResourceManager.Storage.Models.Sku("Standard_LRS"),
                Kind.StorageV2,
                "eastus2"
                )
            {
                AccessTier = AccessTier.Hot
            };
            StorageAccountCollection storageAccountCollection = resourceGroup.GetStorageAccounts();
            await storageAccountCollection.CreateOrUpdateAsync(accountName, storageAccountCreateParameters);

            // Create NameSpace
            var namespaceName           = Recording.GenerateAssetName(Helper.NamespacePrefix);
            var createNamespaceResponse = await NamespacesOperations.StartCreateOrUpdateAsync(resourceGroupName, namespaceName,
                                                                                              new EHNamespace()
            {
                Location = location
            }
                                                                                              );

            var np = (await WaitForCompletionAsync(createNamespaceResponse)).Value;

            Assert.NotNull(createNamespaceResponse);
            Assert.AreEqual(np.Name, namespaceName);
            DelayInTest(5);
            // Create Eventhub
            var eventhubName           = Recording.GenerateAssetName(Helper.EventHubPrefix);
            var createEventhubResponse = await EventHubsOperations.CreateOrUpdateAsync(resourceGroupName, namespaceName, eventhubName,
                                                                                       new Eventhub()
            {
                MessageRetentionInDays = 4,
                PartitionCount         = 4,
                Status             = EntityStatus.Active,
                CaptureDescription = new CaptureDescription()
                {
                    Enabled           = true,
                    Encoding          = EncodingCaptureDescription.Avro,
                    IntervalInSeconds = 120,
                    SizeLimitInBytes  = 10485763,
                    Destination       = new Destination()
                    {
                        Name                     = "EventHubArchive.AzureBlockBlob",
                        BlobContainer            = "container",
                        ArchiveNameFormat        = "{Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}",
                        StorageAccountResourceId = "/subscriptions/" + SubscriptionId + "/resourcegroups/" + resourceGroupName + "/providers/Microsoft.Storage/storageAccounts/" + accountName
                    },
                    SkipEmptyArchives = true
                }
            });

            Assert.NotNull(createEventhubResponse);
            Assert.AreEqual(createEventhubResponse.Value.Name, eventhubName);
            Assert.True(createEventhubResponse.Value.CaptureDescription.SkipEmptyArchives);
            //Get the created EventHub
            var getEventHubResponse = await EventHubsOperations.GetAsync(resourceGroupName, namespaceName, eventhubName);

            Assert.NotNull(getEventHubResponse.Value);
            Assert.AreEqual(EntityStatus.Active, getEventHubResponse.Value.Status);
            Assert.AreEqual(getEventHubResponse.Value.Name, eventhubName);
            //Get all Event Hubs for a given NameSpace
            var getListEventHubResponse = EventHubsOperations.ListByNamespaceAsync(resourceGroupName, namespaceName);
            var list = await getListEventHubResponse.ToEnumerableAsync();

            Assert.NotNull(getListEventHubResponse);
            Assert.True(list.Count() >= 1);
            // Update the EventHub
            getEventHubResponse.Value.CaptureDescription.IntervalInSeconds = 130;
            getEventHubResponse.Value.CaptureDescription.SizeLimitInBytes  = 10485900;
            getEventHubResponse.Value.MessageRetentionInDays = 5;
            //TODO time exception
            var UpdateEventHubResponse = (await EventHubsOperations.CreateOrUpdateAsync(resourceGroupName, namespaceName, eventhubName, getEventHubResponse.Value)).Value;

            Assert.NotNull(UpdateEventHubResponse);
            // Get the updated EventHub and verify the properties
            var getEventResponse = await EventHubsOperations.GetAsync(resourceGroupName, namespaceName, eventhubName);

            Assert.NotNull(getEventResponse);
            Assert.AreEqual(EntityStatus.Active, getEventResponse.Value.Status);
            Assert.AreEqual(5, getEventResponse.Value.MessageRetentionInDays);
            // Delete the Evnet Hub
            var deleteEventResponse = await EventHubsOperations.DeleteAsync(resourceGroupName, namespaceName, eventhubName);

            // Delete namespace and check for the NotFound exception
            var deleteNamespaceResponse = await WaitForCompletionAsync(await NamespacesOperations.StartDeleteAsync(resourceGroupName, namespaceName));
        }