• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Blob.CloudBlockBlob类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: TaskMain

        public static void TaskMain(string[] args)
        {
            if (args == null || args.Length != 5)
            {
                throw new Exception("Usage: TopNWordsSample.exe --Task <blobpath> <numtopwords> <storageAccountName> <storageAccountKey>");
            }

            string blobName = args[1];
            int numTopN = int.Parse(args[2]);
            string storageAccountName = args[3];
            string storageAccountKey = args[4];

            // open the cloud blob that contains the book
            var storageCred = new StorageCredentials(storageAccountName, storageAccountKey);
            CloudBlockBlob blob = new CloudBlockBlob(new Uri(blobName), storageCred);
            using (Stream memoryStream = new MemoryStream())
            {
                blob.DownloadToStream(memoryStream);
                memoryStream.Position = 0; //Reset the stream
                var sr = new StreamReader(memoryStream);
                var myStr = sr.ReadToEnd();
                string[] words = myStr.Split(' ');
                var topNWords =
                    words.
                     Where(word => word.Length > 0).
                     GroupBy(word => word, (key, group) => new KeyValuePair<String, long>(key, group.LongCount())).
                     OrderByDescending(x => x.Value).
                     Take(numTopN).
                     ToList();
                foreach (var pair in topNWords)
                {
                    Console.WriteLine("{0} {1}", pair.Key, pair.Value);
                }
            }
        }
开发者ID:romitgirdhar,项目名称:azure-batch-samples,代码行数:35,代码来源:TopNWordsTask.cs


示例2: JobLogBlob

        public JobLogBlob(CloudBlockBlob blob)
        {
            Blob = blob;

            // Parse the name
            var parsed = BlobNameParser.Match(blob.Name);
            if (!parsed.Success)
            {
                throw new ArgumentException("Job Log Blob name is invalid Bob! Expected [jobname].[yyyy-MM-dd].json or [jobname].json. Got: " + blob.Name, "blob");
            }

            // Grab the chunks we care about
            JobName = parsed.Groups["job"].Value;

            string format = DayTimeStamp;
            if (parsed.Groups[1].Success)
            {
                // Has an hour portion!
                format = HourTimeStamp;
            }

            ArchiveTimestamp = DateTime.ParseExact(
                parsed.Groups["timestamp"].Value, 
                format, 
                CultureInfo.InvariantCulture);
        }
开发者ID:atrevisan,项目名称:NuGetGallery,代码行数:26,代码来源:JobLogBlob.cs


示例3: uploadfromFilesystem

 public void uploadfromFilesystem(CloudBlockBlob blob, string localFilePath, string eventType)
 {
     if (eventType.Equals("create") || eventType.Equals("signUpStart"))
     {
         Program.ClientForm.addtoConsole("Upload started[create || signUpStart]:" + localFilePath);
         blob.UploadFromFile(localFilePath, FileMode.Open);
         Program.ClientForm.addtoConsole("Uploaded");
         Program.ClientForm.ballon("Uploaded:"+ localFilePath);
     }
     else
     {
         try
         {
             Program.ClientForm.addtoConsole("Upload started[change,etc]:" + localFilePath);
             string leaseId = Guid.NewGuid().ToString();
             blob.AcquireLease(TimeSpan.FromMilliseconds(16000), leaseId);
             blob.UploadFromFile(localFilePath, FileMode.Open, AccessCondition.GenerateLeaseCondition(leaseId));
             blob.ReleaseLease(AccessCondition.GenerateLeaseCondition(leaseId));
             Program.ClientForm.addtoConsole("Uploaded");
             Program.ClientForm.ballon("Uploaded:" + localFilePath);
         }
         catch (Exception ex)
         {
             Program.ClientForm.addtoConsole("Upload: second attempt");
             Thread.Sleep(5000);
             string leaseId = Guid.NewGuid().ToString();
             blob.AcquireLease(TimeSpan.FromMilliseconds(16000), leaseId);
             blob.UploadFromFile(localFilePath, FileMode.Open, AccessCondition.GenerateLeaseCondition(leaseId));
             blob.ReleaseLease(AccessCondition.GenerateLeaseCondition(leaseId));
             Program.ClientForm.addtoConsole("Uploaded");
             Program.ClientForm.ballon("Uploaded:" + localFilePath);
         }
     }
 }
开发者ID:hangmiao,项目名称:DBLike,代码行数:34,代码来源:LocalFileSys.cs


示例4: WaitForBlobAsync

 public static async Task WaitForBlobAsync(CloudBlockBlob blob)
 {
     await TestHelpers.Await(() =>
     {
         return blob.Exists();
     });
 }
开发者ID:Azure,项目名称:azure-webjobs-sdk-script,代码行数:7,代码来源:TestHelpers.cs


示例5: BlobFileSinkStreamProvider

        public BlobFileSinkStreamProvider(CloudBlockBlob blob, bool overwrite)
        {
            Guard.NotNull("blob", blob);

            this.blob = blob;
            this.overwrite = overwrite;
        }
开发者ID:kingkino,项目名称:azure-documentdb-datamigrationtool,代码行数:7,代码来源:BlobFileSinkStreamProvider.cs


示例6: revertFromSnapshot

        public void revertFromSnapshot(CloudBlockBlob blobRef, CloudBlockBlob snapshot)
        {
            try
            {

                    blobRef.StartCopyFromBlob(snapshot);
                    DateTime timestamp = DateTime.Now;
                    blobRef.FetchAttributes();
                    snapshot.FetchAttributes();
                    string time = snapshot.Metadata["timestamp"];
                    blobRef.Metadata["timestamp"] = timestamp.ToUniversalTime().ToString("MM/dd/yyyy HH:mm:ss");
                    blobRef.SetMetadata();
                    blobRef.CreateSnapshot();
                    //System.Windows.Forms.MessageBox.Show("revert success");

                    Program.ClientForm.addtoConsole("Successfully Reverted with time: " + time);
                    Program.ClientForm.ballon("Successfully Reverted! ");

            }
            catch (Exception e)
            {
                Program.ClientForm.addtoConsole("Exception:" + e.Message);
                //System.Windows.Forms.MessageBox.Show(e.ToString());
            }
        }
开发者ID:hangmiao,项目名称:DBLike,代码行数:25,代码来源:VCmanager.revert.cs


示例7: deleteSnapshot

        public void deleteSnapshot(CloudBlockBlob blobRef)
        {
            string blobPrefix = null;
            bool useFlatBlobListing = true;

            var snapshots = container.ListBlobs(blobPrefix, useFlatBlobListing,
            BlobListingDetails.Snapshots).Where(item => ((CloudBlockBlob)item).SnapshotTime.HasValue && item.Uri.Equals(blobRef.Uri)).ToList<IListBlobItem>();

            if (snapshots.Count < 1)
            {
                Console.WriteLine("snapshot was not created");
            }
            else
            {
                foreach (IListBlobItem item in snapshots)
                {
                    CloudBlockBlob blob = (CloudBlockBlob)item;

                    blob.DeleteIfExists();
                    Console.WriteLine("Delete Name: {0}, Timestamp: {1}", blob.Name, blob.SnapshotTime);
                    Console.WriteLine("success");
                }
                //snapshots.ForEach(item => Console.WriteLine(String.Format("{0} {1} ", ((CloudBlockBlob)item).Name, ((CloudBlockBlob)item).Metadata["timestamp"])));
            }
        }
开发者ID:hangmiao,项目名称:DBLike,代码行数:25,代码来源:VCmanager.cs


示例8: JobLogBlob

        public JobLogBlob(CloudBlockBlob blob)
        {
            Blob = blob;

            // Parse the name
            var parsed = BlobNameParser.Match(blob.Name);
            if (!parsed.Success)
            {
                throw new ArgumentException(string.Format(NuGetGallery.Strings.JobLogBlobNameInvalid, blob.Name), nameof(blob));
            }

            // Grab the chunks we care about
            JobName = parsed.Groups["job"].Value;

            string format = DayTimeStamp;
            if (parsed.Groups[1].Success)
            {
                // Has an hour portion!
                format = HourTimeStamp;
            }

            ArchiveTimestamp = DateTime.ParseExact(
                parsed.Groups["timestamp"].Value, 
                format, 
                CultureInfo.InvariantCulture);
        }
开发者ID:ZhiYuanHuang,项目名称:NuGetGallery,代码行数:26,代码来源:JobLogBlob.cs


示例9: ValidatePipelineICloudBlobSuccessfullyTest

        public void ValidatePipelineICloudBlobSuccessfullyTest()
        {
            AddTestBlobs();

            CloudBlockBlob blob = new CloudBlockBlob(new Uri("http://127.0.0.1/account/container1/blob0"));
            command.ValidatePipelineICloudBlob(blob);
        }
开发者ID:takekazuomi,项目名称:azure-sdk-tools,代码行数:7,代码来源:StorageCloudBlobCmdletBaseTest.cs


示例10: EndpointToHost

 public EndpointToHost(CloudBlockBlob blob)
 {
     this.blob = blob;
     this.blob.FetchAttributes();
     EndpointName = Path.GetFileNameWithoutExtension(blob.Uri.AbsolutePath);
     LastUpdated = blob.Properties.LastModified.HasValue ? blob.Properties.LastModified.Value.DateTime : default(DateTime);
 }
开发者ID:mjhilton,项目名称:NServiceBus.Host.AzureCloudService,代码行数:7,代码来源:EndpointToHost.cs


示例11: AddContainerMetadata

        public static void AddContainerMetadata(CloudBlockBlob blob, object fileUploadObj)
        {
            var obj = ((BlobStorage.Models.UploadDataModel)fileUploadObj);
            //Add some metadata to the container.


            if (IsNotNull(obj.Category))
                blob.Metadata["category"] = obj.Category;
            else
                blob.Metadata["category"] = "Other";

            if (IsNotNull(obj.Name))
                blob.Metadata["name"] = obj.Name;
            else
                blob.Metadata["name"] = "Null";

            if (IsNotNull(obj.Number))
                blob.Metadata["number"] = obj.Number;
            else
                blob.Metadata["number"] = "Null";

            if (IsNotNull(obj.Email))
                blob.Metadata["email"] = obj.Email;
            else
                blob.Metadata["email"] = "Null";

            if (IsNotNull(obj.Comments))
                blob.Metadata["comments"] = obj.Comments;
            else
                blob.Metadata["comments"] = "Null";

            //Set the container's metadata.
            blob.SetMetadata();
        }
开发者ID:rohngonnarock,项目名称:BlobStorage,代码行数:34,代码来源:Todo.cs


示例12: RunAsync

        /// <summary>
        /// Runs the mapper task.
        /// </summary>
        public async Task RunAsync()
        {
            CloudBlockBlob blob = new CloudBlockBlob(new Uri(this.blobSas));
            Console.WriteLine("Matches in blob: {0}/{1}", blob.Container.Name, blob.Name);

            using (Stream memoryStream = new MemoryStream())
            {
                //Download the blob.
                await blob.DownloadToStreamAsync(memoryStream);
                memoryStream.Seek(0, SeekOrigin.Begin);

                using (StreamReader streamReader = new StreamReader(memoryStream))
                {
                    Regex regex = new Regex(this.configurationSettings.RegularExpression);

                    int lineCount = 0;

                    //Read the file content.
                    while (!streamReader.EndOfStream)
                    {
                        ++lineCount;
                        string textLine = await streamReader.ReadLineAsync();

                        //If the line matches the search parameters, then print it out.
                        if (textLine.Length > 0)
                        {
                            if (regex.Match(textLine).Success)
                            {
                                Console.WriteLine("Match: \"{0}\" -- line: {1}", textLine, lineCount);
                            }
                        }
                    }
                }
            }
        }
开发者ID:Wahesh,项目名称:azure-batch-samples,代码行数:38,代码来源:MapperTask.cs


示例13: GetTitle

 protected String GetTitle(Uri blobURI)
 {
     //returns the title of the file from the Blob metadata
     CloudBlockBlob blob = new CloudBlockBlob(blobURI);
     blob.FetchAttributes();
     return blob.Metadata["Title"];
 }
开发者ID:crai9,项目名称:MP3-Shortener,代码行数:7,代码来源:Default.aspx.cs


示例14: Main

        public static void Main(string[] args)
        {
            Console.WriteLine("Press any key to run sample...");
            Console.ReadKey();

            // Make sure the endpoint matches with the web role's endpoint.
            var tokenServiceEndpoint = ConfigurationManager.AppSettings["serviceEndpointUrl"];

            try
            {
                var blobSas = GetBlobSas(new Uri(tokenServiceEndpoint)).Result;

                // Create storage credentials object based on SAS
                var credentials = new StorageCredentials(blobSas.Credentials);

                // Using the returned SAS credentials and BLOB Uri create a block blob instance to upload
                var blob = new CloudBlockBlob(blobSas.BlobUri, credentials);

                using (var stream = GetFileToUpload(10))
                {
                    blob.UploadFromStream(stream);
                }

                Console.WriteLine("Blob uplodad successful: {0}", blobSas.Name);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            
            Console.WriteLine();
            Console.WriteLine("Done. Press any key to exit...");
            Console.ReadKey();
        }
开发者ID:mspnp,项目名称:cloud-design-patterns,代码行数:34,代码来源:Program.cs


示例15: DownloadBlob

 private static string DownloadBlob(CloudBlockBlob blob)
 {
     using (var stream = new MemoryStream())
     {
         StreamReader reader;
         try
         {
             blob.DownloadToStream(stream, options: new BlobRequestOptions()
             {
                 RetryPolicy = new LinearRetry(TimeSpan.FromSeconds(5), 3)
             });
         }
         catch (StorageException se)
         {
             return "";
         }
         try
         {
             stream.Seek(0, 0);
             reader = new StreamReader(new GZipStream(stream, CompressionMode.Decompress));
             return reader.ReadToEnd();
         }
         catch
         {
             stream.Seek(0, 0);
             reader = new StreamReader(stream);
             return reader.ReadToEnd();
         }
     }
 }
开发者ID:postworthy,项目名称:postworthy,代码行数:30,代码来源:Program.cs


示例16: GetInstanceIndex

 protected String GetInstanceIndex(Uri blobURI)
 {
     //returns the Worker role's index from the Blob metadata
     CloudBlockBlob blob = new CloudBlockBlob(blobURI);
     blob.FetchAttributes();
     return blob.Metadata["InstanceNo"];
 }
开发者ID:crai9,项目名称:MP3-Shortener,代码行数:7,代码来源:Default.aspx.cs


示例17: GetBlobMetadata

 public object GetBlobMetadata(CloudBlockBlob blob, string metadataKey) {
     if(blob.Metadata.ContainsKey(metadataKey)) {
         return blob.Metadata[metadataKey];
     } else {
         return null;
     }
 }
开发者ID:cberio,项目名称:thisistracer,代码行数:7,代码来源:PhotoMapRepository.cs


示例18: UploadDocument

 private static void UploadDocument(CloudBlockBlob blob, String path)
 {
     using (var fileStream = File.OpenRead(path))
     {
         blob.UploadFromStream(fileStream);
     }
 }
开发者ID:PeLoSTA,项目名称:Wpf_Cloud_01_Blobs,代码行数:7,代码来源:MainWindow.xaml.cs


示例19: ArchiveOriginalPackageBlob

        /// <summary>
        /// Creates an archived copy of the original package blob if it doesn't already exist.
        /// </summary>
        private void ArchiveOriginalPackageBlob(CloudBlockBlob originalPackageBlob, CloudBlockBlob latestPackageBlob)
        {
            // Copy the blob to backup only if it isn't already successfully copied
            if ((!originalPackageBlob.Exists()) || (originalPackageBlob.CopyState != null && originalPackageBlob.CopyState.Status != CopyStatus.Success))
            {
                if (!WhatIf)
                {
                    Log.Info("Backing up blob: {0} to {1}", latestPackageBlob.Name, originalPackageBlob.Name);
                    originalPackageBlob.StartCopyFromBlob(latestPackageBlob);
                    CopyState state = originalPackageBlob.CopyState;

                    for (int i = 0; (state == null || state.Status == CopyStatus.Pending) && i < SleepTimes.Length; i++)
                    {
                        Log.Info("(sleeping for a copy completion)");
                        Thread.Sleep(SleepTimes[i]); 
                        originalPackageBlob.FetchAttributes(); // To get a refreshed CopyState

                        //refresh state
                        state = originalPackageBlob.CopyState;
                    }

                    if (state.Status != CopyStatus.Success)
                    {
                        string msg = string.Format("Blob copy failed: CopyState={0}", state.StatusDescription);
                        Log.Error("(error) " + msg);
                        throw new BlobBackupFailedException(msg);
                    }
                }
            }
        }
开发者ID:hermanocabral,项目名称:NuGetGallery,代码行数:33,代码来源:HandleQueuedPackageEditsTask.cs


示例20: ValueWatcherCommand

 public ValueWatcherCommand(IReadOnlyDictionary<string, IWatcher> watches, CloudBlockBlob blobResults,
     TextWriter consoleOutput)
 {
     _blobResults = blobResults;
     _consoleOutput = consoleOutput;
     _watches = watches;
 }
开发者ID:chungvinhkhang,项目名称:azure-webjobs-sdk,代码行数:7,代码来源:ValueWatcher.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Blob.CloudPageBlob类代码示例发布时间:2022-05-26
下一篇:
C# Blob.CloudBlobContainer类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap