示例#1
0
        public async Task Batch_CanUseResponseAfterException()
        {
            await using TestScenario scenario = Scenario();
            Uri[] good = await scenario.CreateBlobUrisAsync(1);

            Uri[] bad = scenario.GetInvalidBlobUris(1);

            BlobBatchClient client = scenario.GetBlobBatchClient();

            using BlobBatch batch = client.CreateBatch();
            Response response1 = batch.DeleteBlob(good[0]);
            Response response2 = batch.DeleteBlob(bad[0]);

            try
            {
                await client.SubmitBatchAsync(batch);
            }
            catch (AggregateException)
            {
                // Swallow the exception
            }

            scenario.AssertStatus(202, response1);
            scenario.AssertStatus(404, response2);
        }
示例#2
0
        public async Task Batch_AcrossContainers()
        {
            await using TestScenario scenario = Scenario();
            BlobContainerClient container1 = await scenario.CreateContainerAsync();

            Uri[] blobs1 = await scenario.CreateBlobUrisAsync(container1, 2);

            BlobContainerClient container2 = await scenario.CreateContainerAsync();

            Uri[] blobs2 = await scenario.CreateBlobUrisAsync(container2, 3);

            Uri[] blobs = blobs1.Concat(blobs2).ToArray();

            BlobBatchClient client = scenario.GetBlobBatchClient();

            Response[] responses = await client.DeleteBlobsAsync(blobs);

            scenario.AssertStatus(202, responses);
        }
示例#3
0
        public async Task Batch_SasUri_NotOwner()
        {
            // Create a container using SAS for Auth
            string containerName = GetNewContainerName();

            await using DisposingContainer test = await GetTestContainerAsync();

            await using TestScenario scenario = Scenario(GetServiceClient_BlobServiceSas_Container(containerName));
            Uri[] blobs = await scenario.CreateBlobUrisAsync(test.Container, 2);

            BlobBatchClient        client = scenario.GetBlobBatchClient();
            RequestFailedException ex     = Assert.ThrowsAsync <RequestFailedException>(
                async() => await client.DeleteBlobsAsync(blobs));

            Assert.AreEqual(403, ex.Status);
        }
示例#4
0
        public async Task Batch_Limit()
        {
            await using TestScenario scenario = Scenario();
            Uri[] blobs = await scenario.CreateBlobUrisAsync(257);

            BlobBatchClient client = scenario.GetBlobBatchClient();

            // One over the limit
            RequestFailedException ex = Assert.ThrowsAsync <RequestFailedException>(
                async() => await client.DeleteBlobsAsync(blobs));

            Assert.AreEqual(400, ex.Status);
            Assert.AreEqual("ExceedsMaxBatchRequestCount", ex.ErrorCode);

            // The exact limit
            await client.DeleteBlobsAsync(blobs.Take(256).ToArray());
        }
示例#5
0
        public async Task Batch_AzureSasCredential()
        {
            // Create a container using SAS for Auth
            await using DisposingContainer test = await GetTestContainerAsync();

            var serviceClient    = GetServiceClient_SharedKey();
            var sas              = GetAccountSasCredentials().SasToken;
            var sasServiceClient = InstrumentClient(new BlobServiceClient(serviceClient.Uri, new AzureSasCredential(sas), GetOptions()));

            await using TestScenario scenario = Scenario(sasServiceClient);
            Uri[] blobs = await scenario.CreateBlobUrisAsync(test.Container, 2);

            BlobBatchClient client = scenario.GetBlobBatchClient();

            Response[] responses = await client.DeleteBlobsAsync(blobs);

            scenario.AssertStatus(202, responses);
        }