当前位置: 首页>>代码示例>>C#>>正文


C# BlobServiceClient类代码示例

本文整理汇总了C#中BlobServiceClient的典型用法代码示例。如果您正苦于以下问题:C# BlobServiceClient类的具体用法?C# BlobServiceClient怎么用?C# BlobServiceClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BlobServiceClient类属于命名空间,在下文中一共展示了BlobServiceClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateContainer_ValidArgumentsWithNoPublicAccess_CreatesContainerWithNoPublicAccess

        public void CreateContainer_ValidArgumentsWithNoPublicAccess_CreatesContainerWithNoPublicAccess()
        {
            var containerName = GenerateSampleContainerName();
            IBlobServiceClient client = new BlobServiceClient(AccountSettings);

            client.CreateContainer(containerName, ContainerAccessType.None);

            AssertContainerAccess(containerName, Microsoft.WindowsAzure.Storage.Blob.BlobContainerPublicAccessType.Off);
        }
开发者ID:renlesterdg,项目名称:BasicAzureStorageSDK,代码行数:9,代码来源:BlobServiceClientTests.cs

示例2: CreateContainer_ValidArguments_CreatesContainerWithSpecificName

        public void CreateContainer_ValidArguments_CreatesContainerWithSpecificName()
        {
            var containerName = GenerateSampleContainerName();
            IBlobServiceClient client = new BlobServiceClient(AccountSettings);

            client.CreateContainer(containerName, ContainerAccessType.None);

            AssertContainerExists(containerName);
        }
开发者ID:renlesterdg,项目名称:BasicAzureStorageSDK,代码行数:9,代码来源:BlobServiceClientTests.cs

示例3: CreateContainer_AlreadyExists_ThrowsContainerAlreadyExistsException

        public void CreateContainer_AlreadyExists_ThrowsContainerAlreadyExistsException()
        {
            var containerName = GenerateSampleContainerName();
            CreateContainer(containerName);
            IBlobServiceClient client = new BlobServiceClient(AccountSettings);

            client.CreateContainer(containerName, ContainerAccessType.None);

            // expects exception
        }
开发者ID:renlesterdg,项目名称:BasicAzureStorageSDK,代码行数:10,代码来源:BlobServiceClientTests.cs

示例4: CopyBlob_EmptyContainerNameGiven_ThrowsArgumentNullException

        public void CopyBlob_EmptyContainerNameGiven_ThrowsArgumentNullException()
        {
            var blobName = _util.GenerateSampleBlobName(_runId);
            var fakeUri = "https://foo.foo.foo/";
            IBlobServiceClient client = new BlobServiceClient(AccountSettings);

            client.CopyBlob("", blobName, fakeUri);

            // throws exception
        }
开发者ID:BrianMcBrayer,项目名称:BasicAzureStorageSDK,代码行数:10,代码来源:BlobOperationsTests.cs

示例5: CopyBlob_RequiredArgsOnly_BeginsCopyOperation

        public void CopyBlob_RequiredArgsOnly_BeginsCopyOperation()
        {
            var containerName = _util.GenerateSampleContainerName(_runId);
            var blobName = _util.GenerateSampleBlobName(_runId);
            _util.CreateContainer(containerName);
            var blobUri = _util.CreateBlockBlob(containerName, blobName).Uri;
            IBlobServiceClient client = new BlobServiceClient(AccountSettings);

            client.CopyBlob(containerName, blobName, blobUri.ToString());

            _util.AssertBlobCopyOperationInProgressOrSuccessful(containerName, blobName);
        }
开发者ID:BrianMcBrayer,项目名称:BasicAzureStorageSDK,代码行数:12,代码来源:BlobOperationsTests.cs

示例6: PutBlockListAsync_LeasedBlobWithInvalidLeaseGiven_ThrowsArgumentException

        public async void PutBlockListAsync_LeasedBlobWithInvalidLeaseGiven_ThrowsArgumentException()
        {
            var containerName = _util.GenerateSampleContainerName(_runId);
            var blobName = _util.GenerateSampleBlobName(_runId);
            var blockListBlockIds = _util.CreateBlockIdList(3, PutBlockListListType.Latest);
            IBlobServiceClient client = new BlobServiceClient(AccountSettings);

            await client.PutBlockListAsync(containerName, blobName, blockListBlockIds, leaseId: InvalidLeaseId);

            // throws exception
        }
开发者ID:BrianMcBrayer,项目名称:BasicAzureStorageSDK,代码行数:11,代码来源:BlobOperationsTests.cs

示例7: LeaseBlobBreak_LeasedBlob_BreaksLease

        public void LeaseBlobBreak_LeasedBlob_BreaksLease()
        {
            IBlobServiceClient client = new BlobServiceClient(AccountSettings);
            var containerName = _util.GenerateSampleContainerName(_runId);
            var blobName = _util.GenerateSampleBlobName(_runId);
            _util.CreateContainer(containerName);
            _util.CreateBlockBlob(containerName, blobName);
            var leaseId = _util.LeaseBlob(containerName, blobName);

            client.LeaseBlobBreak(containerName, blobName, leaseId, 0);

            var leaseState = _util.GetBlobLeaseState(containerName, blobName);
            Assert.AreEqual(Microsoft.WindowsAzure.Storage.Blob.LeaseState.Broken, leaseState);
        }
开发者ID:BrianMcBrayer,项目名称:BasicAzureStorageSDK,代码行数:14,代码来源:BlobOperationsTests.cs

示例8: PutBlockList_LeasedBlobWithNoLeaseGiven_ThrowsLeaseIdMissingAzureException

        public void PutBlockList_LeasedBlobWithNoLeaseGiven_ThrowsLeaseIdMissingAzureException()
        {
            const string dataPerBlock = "foo";
            var containerName = _util.GenerateSampleContainerName(_runId);
            var blobName = _util.GenerateSampleBlobName(_runId);
            _util.CreateContainer(containerName);
            _util.CreateBlockBlob(containerName, blobName);
            var blockListBlockIds = _util.CreateBlockIdList(3, PutBlockListListType.Latest);
            var blockIds = _util.GetIdsFromBlockIdList(blockListBlockIds);
            _util.CreateBlockList(containerName, blobName, blockIds, dataPerBlock);
            _util.LeaseBlob(containerName, blobName);
            IBlobServiceClient client = new BlobServiceClient(AccountSettings);

            client.PutBlockList(containerName, blobName, blockListBlockIds);

            // throws exception
        }
开发者ID:BrianMcBrayer,项目名称:BasicAzureStorageSDK,代码行数:17,代码来源:BlobOperationsTests.cs

示例9: BlobServiceClient

        public async void PutBlockListAsync_LeasedBlobWithIncorrectLeaseGiven_ThrowsLeaseIdMismatchWithBlobOperationAzureException()
        {
            const string dataPerBlock = "foo";
            var containerName = _util.GenerateSampleContainerName(_runId);
            var blobName = _util.GenerateSampleBlobName(_runId);
            _util.CreateContainer(containerName);
            _util.CreateBlockBlob(containerName, blobName);
            var blockListBlockIds = _util.CreateBlockIdList(3, PutBlockListListType.Latest);
            var blockIds = _util.GetIdsFromBlockIdList(blockListBlockIds);
            _util.CreateBlockList(containerName, blobName, blockIds, dataPerBlock);
            _util.LeaseBlob(containerName, blobName);
            IBlobServiceClient client = new BlobServiceClient(AccountSettings);

            await client.PutBlockListAsync(containerName, blobName, blockListBlockIds, leaseId: GetGuidString());

            // throws exception
        }
开发者ID:BrianMcBrayer,项目名称:BasicAzureStorageSDK,代码行数:17,代码来源:BlobOperationsTests.cs

示例10: PutBlockBlobAsync_LeasedBlobWithNoLeaseGiven_ThrowsLeaseIdMissingAzureException

        public async void PutBlockBlobAsync_LeasedBlobWithNoLeaseGiven_ThrowsLeaseIdMissingAzureException()
        {
            var containerName = _util.GenerateSampleContainerName(_runId);
            var blobName = _util.GenerateSampleBlobName(_runId);
            _util.CreateContainer(containerName);
            _util.CreateBlockBlob(containerName, blobName);
            _util.LeaseBlob(containerName, blobName);
            IBlobServiceClient client = new BlobServiceClient(AccountSettings);
            var data = Encoding.UTF8.GetBytes("unit test content");

            await client.PutBlockBlobAsync(containerName, blobName, data);

            // throws exception
        }
开发者ID:BrianMcBrayer,项目名称:BasicAzureStorageSDK,代码行数:14,代码来源:BlobOperationsTests.cs

示例11: LeaseBlobRenewAsync_LeasedBlob_RenewsActiveLease

        public async void LeaseBlobRenewAsync_LeasedBlob_RenewsActiveLease()
        {
            var minimumWaitTime = TimeSpan.FromSeconds(15);
            var halfOfMinimum = minimumWaitTime.Subtract(TimeSpan.FromSeconds(minimumWaitTime.TotalSeconds * 0.5));
            var threeQuartersOfMinimum = minimumWaitTime.Subtract(TimeSpan.FromSeconds(minimumWaitTime.TotalSeconds * 0.75));
            IBlobServiceClient client = new BlobServiceClient(AccountSettings);
            var containerName = _util.GenerateSampleContainerName(_runId);
            var blobName = _util.GenerateSampleBlobName(_runId);
            _util.CreateContainer(containerName);
            _util.CreateBlockBlob(containerName, blobName);
            var leaseId = _util.LeaseBlob(containerName, blobName, TimeSpan.FromSeconds(15));
            Thread.Sleep(halfOfMinimum);

            await client.LeaseBlobRenewAsync(containerName, blobName, leaseId);

            Thread.Sleep(threeQuartersOfMinimum); // wait again... if it didn't renew, by now it would be expired
            _util.AssertBlobIsLeased(containerName, blobName, leaseId);
        }
开发者ID:BrianMcBrayer,项目名称:BasicAzureStorageSDK,代码行数:18,代码来源:BlobOperationsTests.cs

示例12: PutBlockList_WithBlobContentEncoding_UploadsWithSpecifiedBlobContentEncoding

        public void PutBlockList_WithBlobContentEncoding_UploadsWithSpecifiedBlobContentEncoding()
        {
            const string dataPerBlock = "foo";
            const string expectedContentEncoding = "UTF32";
            var containerName = _util.GenerateSampleContainerName(_runId);
            var blobName = _util.GenerateSampleBlobName(_runId);
            _util.CreateContainer(containerName);
            var blockListBlockIds = _util.CreateBlockIdList(3, PutBlockListListType.Latest);
            var blockIds = _util.GetIdsFromBlockIdList(blockListBlockIds);
            _util.CreateBlockList(containerName, blobName, blockIds, dataPerBlock, Encoding.UTF32);
            IBlobServiceClient client = new BlobServiceClient(AccountSettings);

            client.PutBlockList(containerName, blobName, blockListBlockIds, contentEncoding: expectedContentEncoding);

            var blob = _util.AssertBlobExists(containerName, blobName, BlobType.BlockBlob);
            Assert.AreEqual(expectedContentEncoding, blob.Properties.ContentEncoding);
        }
开发者ID:BrianMcBrayer,项目名称:BasicAzureStorageSDK,代码行数:17,代码来源:BlobOperationsTests.cs

示例13: PutBlockBlob_RequiredArgsOnly_UploadsBlobSuccessfully

        public void PutBlockBlob_RequiredArgsOnly_UploadsBlobSuccessfully()
        {
            var containerName = _util.GenerateSampleContainerName(_runId);
            var blobName = _util.GenerateSampleBlobName(_runId);
            _util.CreateContainer(containerName);
            IBlobServiceClient client = new BlobServiceClient(AccountSettings);
            var data = Encoding.UTF8.GetBytes("unit test content");

            client.PutBlockBlob(containerName, blobName, data);

            _util.AssertBlobExists(containerName, blobName, BlobType.BlockBlob);
        }
开发者ID:BrianMcBrayer,项目名称:BasicAzureStorageSDK,代码行数:12,代码来源:BlobOperationsTests.cs

示例14: PutBlockListAsync_InvalidBlockId_ThrowsInvalidBlockListAzureException

        public async void PutBlockListAsync_InvalidBlockId_ThrowsInvalidBlockListAzureException()
        {
            const string dataPerBlock = "foo";
            var containerName = _util.GenerateSampleContainerName(_runId);
            var blobName = _util.GenerateSampleBlobName(_runId);
            _util.CreateContainer(containerName);
            var blockListBlockIds = _util.CreateBlockIdList(3, PutBlockListListType.Latest);
            var blockIds = _util.GetIdsFromBlockIdList(blockListBlockIds);
            blockListBlockIds.Add(new BlockListBlockId
            {
                Id = Base64Converter.ConvertToBase64("id4"),
                ListType = PutBlockListListType.Latest
            });
            _util.CreateBlockList(containerName, blobName, blockIds, dataPerBlock);
            IBlobServiceClient client = new BlobServiceClient(AccountSettings);

            await client.PutBlockListAsync(containerName, blobName, blockListBlockIds);

            // Throws exception
        }
开发者ID:BrianMcBrayer,项目名称:BasicAzureStorageSDK,代码行数:20,代码来源:BlobOperationsTests.cs

示例15: LeaseBlobRenewAsync_RecentlyLeasedBlob_RenewsLease

        public async void LeaseBlobRenewAsync_RecentlyLeasedBlob_RenewsLease()
        {
            var minimumWaitTime = TimeSpan.FromSeconds(15);
            var moreThanMinimumWaitTime = minimumWaitTime.Add(TimeSpan.FromSeconds(1));
            IBlobServiceClient client = new BlobServiceClient(AccountSettings);
            var containerName = _util.GenerateSampleContainerName(_runId);
            var blobName = _util.GenerateSampleBlobName(_runId);
            _util.CreateContainer(containerName);
            _util.CreateBlockBlob(containerName, blobName);
            var leaseId = _util.LeaseBlob(containerName, blobName, TimeSpan.FromSeconds(15));
            Thread.Sleep(moreThanMinimumWaitTime);

            await client.LeaseBlobRenewAsync(containerName, blobName, leaseId);

            _util.AssertBlobIsLeased(containerName, blobName, leaseId);
        }
开发者ID:BrianMcBrayer,项目名称:BasicAzureStorageSDK,代码行数:16,代码来源:BlobOperationsTests.cs


注:本文中的BlobServiceClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。