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


C# Agent.StartAzureStorageBlobCopy方法代码示例

本文整理汇总了C#中Agent.StartAzureStorageBlobCopy方法的典型用法代码示例。如果您正苦于以下问题:C# Agent.StartAzureStorageBlobCopy方法的具体用法?C# Agent.StartAzureStorageBlobCopy怎么用?C# Agent.StartAzureStorageBlobCopy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Agent的用法示例。


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

示例1: StartCopyBlobTest

        internal void StartCopyBlobTest(Agent agent, bool useUri)
        {
            CloudBlobUtil blobUtil = new CloudBlobUtil(CommonStorageAccount);
            blobUtil.SetupTestContainerAndBlob();
            string copiedName = Utility.GenNameString("copied");

            if (useUri)
            {
                //Set the blob permission, so the copy task could directly copy by uri
                BlobContainerPermissions permission = new BlobContainerPermissions();
                permission.PublicAccess = BlobContainerPublicAccessType.Blob;
                blobUtil.Container.SetPermissions(permission);
            }

            try
            {
                if (useUri)
                {
                    Test.Assert(agent.StartAzureStorageBlobCopy(blobUtil.Blob.Uri.ToString(), blobUtil.ContainerName, copiedName, PowerShellAgent.Context), Utility.GenComparisonData("Start copy blob using source uri", true));
                }
                else
                {
                    Test.Assert(agent.StartAzureStorageBlobCopy(blobUtil.ContainerName, blobUtil.BlobName, blobUtil.ContainerName, copiedName), Utility.GenComparisonData("Start copy blob using blob name", true));
                }

                Test.Info("Get destination blob in copy task");
                ICloudBlob blob = blobUtil.Container.GetBlobReferenceFromServer(copiedName);
                Test.Assert(blob != null, "Destination blob should exist after start copy. If not, please check it's a test issue or dev issue.");

                string sourceUri = CloudBlobUtil.ConvertCopySourceUri(blobUtil.Blob.Uri.ToString());

                Test.Assert(blob.BlobType == blobUtil.Blob.BlobType, String.Format("The destination blob type should be {0}, actually {1}.", blobUtil.Blob.BlobType, blob.BlobType));

                Test.Assert(blob.CopyState.Source.ToString().StartsWith(sourceUri), String.Format("The source of destination blob should start with {0}, and actually it's {1}", sourceUri, blob.CopyState.Source.ToString()));
            }
            finally
            {
                blobUtil.CleanupTestContainerAndBlob();
            }
        }
开发者ID:B-Rich,项目名称:azure-sdk-tools,代码行数:40,代码来源:StorageBVT.cs

示例2: CopyBlobTestGB

        internal void CopyBlobTestGB(Agent agent, StorageBlob.BlobType blobType)
        {
            string uploadFilePath = @".\" + Utility.GenNameString("gbupload");
            string srcContainerName = Utility.GenNameString("gbupload-", 15);
            string destContainerName = Utility.GenNameString("gbupload-", 15);
            string blobName = Path.GetFileName(uploadFilePath);

            // create the container
            StorageBlob.CloudBlobContainer srcContainer = blobUtil.CreateContainer(srcContainerName);
            StorageBlob.CloudBlobContainer destContainer = blobUtil.CreateContainer(destContainerName);

            // Generate a 512 bytes file which contains GB18030 characters
            File.WriteAllText(uploadFilePath, GB18030String);

            string localMd5 = Helper.GetFileContentMD5(uploadFilePath);

            try
            {
                // create source blob
                StorageBlob.ICloudBlob blob = CloudBlobUtil.GetBlob(srcContainer, blobName, blobType);

                // upload file data
                using (var fileStream = System.IO.File.OpenRead(uploadFilePath))
                {
                    blob.UploadFromStream(fileStream);
                    // need to set MD5 as for page blob, it won't set MD5 automatically
                    blob.Properties.ContentMD5 = localMd5;
                    blob.SetProperties();
                }

                //--------------Copy blob operation--------------
                Test.Assert(agent.StartAzureStorageBlobCopy(srcContainerName, blobName, destContainerName, blobName), Utility.GenComparisonData("Start copy blob using blob name", true));

                // Get destination blob
                blob = CloudBlobUtil.GetBlob(destContainer, blobName, blobType);

                // Check MD5               
                blob.FetchAttributes();
                Test.Assert(localMd5 == blob.Properties.ContentMD5,
                    string.Format("blob content md5 should be {0}, and actualy it's {1}", localMd5, blob.Properties.ContentMD5));
            }
            finally
            {
                // cleanup
                srcContainer.DeleteIfExists();
                destContainer.DeleteIfExists();
                File.Delete(uploadFilePath);
            }
        }
开发者ID:FrankSiegemund,项目名称:azure-powershell,代码行数:49,代码来源:BlobContentTest.cs


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