當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。