Ejemplo n.º 1
0
        public async Task CreateDeleteBlobContainer()
        {
            //create blob container
            string        containerName = Recording.GenerateAssetName("testblob");
            BlobContainer container1    = (await _blobContainerContainer.CreateOrUpdateAsync(containerName, new BlobContainerData())).Value;

            Assert.IsNotNull(container1);
            Assert.AreEqual(container1.Id.Name, containerName);

            //validate if created successfully
            BlobContainer container2 = await _blobContainerContainer.GetAsync(containerName);

            AssertBlobContainerEqual(container1, container2);
            Assert.IsTrue(await _blobContainerContainer.CheckIfExistsAsync(containerName));
            Assert.IsFalse(await _blobContainerContainer.CheckIfExistsAsync(containerName + "1"));
            BlobContainerData containerData = container1.Data;

            Assert.IsEmpty(containerData.Metadata);
            Assert.IsFalse(containerData.HasLegalHold);
            Assert.IsNull(containerData.PublicAccess);
            Assert.False(containerData.HasImmutabilityPolicy);

            //delete blob container
            BlobContainerDeleteOperation blobContainerDeleteOperation = await container1.DeleteAsync();

            await blobContainerDeleteOperation.WaitForCompletionResponseAsync();

            //validate if deleted successfully
            BlobContainer blobContainer3 = await _blobContainerContainer.GetIfExistsAsync(containerName);

            Assert.IsNull(blobContainer3);
            Assert.IsFalse(await _blobContainerContainer.CheckIfExistsAsync(containerName));
        }
Ejemplo n.º 2
0
        public async Task GetIfExist()
        {
            #region Snippet:Managing_BlobContainers_GetBlobContainerIfExists
            BlobContainerContainer blobContainerContainer = blobService.GetBlobContainers();
            BlobContainer          blobContainer          = await blobContainerContainer.GetIfExistsAsync("foo");

            if (blobContainer != null)
            {
                Console.WriteLine(blobContainer.Id.Name);
            }
            if (await blobContainerContainer.CheckIfExistsAsync("bar"))
            {
                Console.WriteLine("blob container 'bar' exists");
            }
            #endregion
        }