Example #1
0
        public async Task CreateDeleteStorageAccount()
        {
            //create storage account
            string accountName = await CreateValidAccountNameAsync(namePrefix);

            _resourceGroup = await CreateResourceGroupAsync();

            StorageAccountContainer storageAccountContainer = _resourceGroup.GetStorageAccounts();
            StorageAccount          account1 = (await storageAccountContainer.CreateOrUpdateAsync(accountName, GetDefaultStorageAccountParameters())).Value;

            Assert.AreEqual(accountName, account1.Id.Name);
            VerifyAccountProperties(account1, true);
            AssertStorageAccountEqual(account1, await account1.GetAsync());

            //validate if created successfully
            StorageAccount account2 = await storageAccountContainer.GetAsync(accountName);

            VerifyAccountProperties(account2, true);
            AssertStorageAccountEqual(account1, account2);
            StorageAccount account3 = await storageAccountContainer.GetIfExistsAsync(accountName + "1");

            Assert.IsNull(account3);
            Assert.IsTrue(await storageAccountContainer.CheckIfExistsAsync(accountName));
            Assert.IsFalse(await storageAccountContainer.CheckIfExistsAsync(accountName + "1"));

            //delete storage account
            await account1.DeleteAsync();

            //validate if deleted successfully
            Assert.IsFalse(await storageAccountContainer.CheckIfExistsAsync(accountName));
            StorageAccount account4 = await storageAccountContainer.GetIfExistsAsync(accountName);

            Assert.IsNull(account4);
        }
        public async Task CreateEventhubWithParameter()
        {
            //prepare a storage account
            string accountName = Recording.GenerateAssetName("storage");

            Storage.Models.Sku sku             = new Storage.Models.Sku("Standard_LRS");
            var storageAccountCreateParameters = new StorageAccountCreateParameters(sku, Kind.StorageV2, "eastus2")
            {
                AccessTier = AccessTier.Hot
            };
            StorageAccount account = (await _resourceGroup.GetStorageAccounts().CreateOrUpdateAsync(true, accountName, storageAccountCreateParameters)).Value;

            if (Mode != RecordedTestMode.Playback)
            {
                await Task.Delay(5000);
            }

            //create eventhub
            string       eventHubName = Recording.GenerateAssetName("eventhub");
            EventHubData parameter    = new EventHubData()
            {
                MessageRetentionInDays = 4,
                PartitionCount         = 4,
                Status             = EntityStatus.Active,
                CaptureDescription = new CaptureDescription()
                {
                    Enabled           = true,
                    Encoding          = EncodingCaptureDescription.Avro,
                    IntervalInSeconds = 120,
                    SizeLimitInBytes  = 10485763,
                    Destination       = new EventHubDestination()
                    {
                        Name                     = "EventHubArchive.AzureBlockBlob",
                        BlobContainer            = "container",
                        ArchiveNameFormat        = "{Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}",
                        StorageAccountResourceId = account.Id.ToString()
                    }
                }
            };
            EventHub eventHub = (await _eventHubCollection.CreateOrUpdateAsync(true, eventHubName, parameter)).Value;

            //validate
            Assert.NotNull(eventHub);
            Assert.AreEqual(eventHub.Id.Name, eventHubName);
            Assert.AreEqual(eventHub.Data.Status, parameter.Status);
            Assert.AreEqual(eventHub.Data.MessageRetentionInDays, parameter.MessageRetentionInDays);
            Assert.AreEqual(eventHub.Data.PartitionCount, parameter.PartitionCount);
            Assert.AreEqual(eventHub.Data.CaptureDescription.IntervalInSeconds, parameter.CaptureDescription.IntervalInSeconds);
            Assert.AreEqual(eventHub.Data.CaptureDescription.SizeLimitInBytes, parameter.CaptureDescription.SizeLimitInBytes);
            Assert.AreEqual(eventHub.Data.CaptureDescription.Destination.Name, parameter.CaptureDescription.Destination.Name);
            Assert.AreEqual(eventHub.Data.CaptureDescription.Destination.BlobContainer, parameter.CaptureDescription.Destination.BlobContainer);
            Assert.AreEqual(eventHub.Data.CaptureDescription.Destination.StorageAccountResourceId, parameter.CaptureDescription.Destination.StorageAccountResourceId);
            Assert.AreEqual(eventHub.Data.CaptureDescription.Destination.ArchiveNameFormat, parameter.CaptureDescription.Destination.ArchiveNameFormat);

            await account.DeleteAsync(true);
        }
        public async Task Delete()
        {
            #region Snippet:Managing_StorageAccounts_DeleteStorageAccount
            StorageAccountCollection accountCollection = resourceGroup.GetStorageAccounts();
            StorageAccount           storageAccount    = await accountCollection.GetAsync("myAccount");

            await storageAccount.DeleteAsync();

            #endregion
        }
Example #4
0
        public void Dispose()
        {
            if (StorageAccount.Subscription == null)
            {
                return;
            }
            Debug.WriteLine("Deleting storage account...");
            StorageAccount.DeleteAsync().Wait();

            // Verify the deletion only if we're testing the database server itself.
            if (GetType() == typeof(DatabaseServerTests))
            {
                VerifyDeletion();
            }
        }
Example #5
0
 private async Task CleanUpVirtualNetwork()
 {
     if (virtualNetwork != null)
     {
         await virtualNetwork.DeleteAsync(WaitUntil.Completed);
     }
     if (privateDnsZone != null)
     {
         await privateDnsZone.DeleteAsync(WaitUntil.Completed);
     }
     if (storageAccount != null)
     {
         //await StorageManagementClient.StorageAccounts.DeleteAsync(resourceGroup.Data.Name, storageAccount.Name);
         await storageAccount.DeleteAsync(WaitUntil.Completed);
     }
 }