Cloudservie将LocalStroage中的内容通过WAD自动上传到BLOB中

开发云服务程序,如果使用Local stroage存储我们临时生成的日志或者文件并将它们自动上传到BLOB中,可以通过WAD来实现,具体如下:

1.配置webrole,开启Local stroage功能:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAjEAAADLCAIAAAAQm1X1AAAgAElEQVR4nO2dy28b173H5x/IP3ARaBkUBYSIlDbZFd5wlX9ANmEautsBLtC76SJApZq25UIBd0XVRRGgdgxCMT0FdLsJAjhQ82qFUn6ksG4QW7IsyXauxYclPwqUdzEz5/zOY4ZDasg5c/j9YBCQZ85rzozOx+c3R4rTAgAAAMzAyboDAAAAQACcBAAAwBTgJAAAAKYAJwEAADAFOAkAAIApwEkAAABMAU4CAABgCnASAAAAU4CTAAAAmAKcBAAAwBTgJAAAAKYAJwEAADCF1J3UrJWmAkq15qClPTco2KyVhimfjJFWDgAAYFhSdVKzVpqacj3+tebFZVfwXFo8ZTwXHgKDsAZyTtZPEBiGFJ3UrJVOaZSRagNOAoOBSS3X4PbllPScFKMkEs8Lc3juVKlWc0mQz3OFmB9RSFi8VKuFiVQwHk103WCpxqsTv4Vf5cpj+wYmkbW1tSOQW+CknJKqk/TzN4nI8Rc5nsskwM9HmSY43ayVpvo4SVWI109jCfsGJg44KdfASTll9OskMd1z/S+RCx05UVBdX8EQJUnrrqjKk/YNTBxra2svQG6Bk3LK6N8nZeIk3igrDyeBwYCTco3qpBMdmTxaIIZU992RoFerxfbdSfGx+DBdwtgdkQmP2JHi7KMQkesbu4vpG5g41tbW/g/kFq2Tzpw5I/03k0cLxJD27yeRLQN8MueJ2rk+3kk8Ckf2OJDQnOvqirN9Ea4brrOCEpF7HOL7BiYOOCnXJFwnqbTb7UyeN+CTq7/jcPrd5nmkXnYCyvUhim9WC06hujlc25vVQtj4EHX4PS9UN0/Vh36MrPIYJ9045zjnbogJM7/5G/0g8bffzIQjqT0fz41zQcG//WZmmPLJGGnlYydmneTDVkuUS5cuQUvZkicnaffVWc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enpGRw4cODI9oCTjGZ6eibrLgAAwPiAk4wGTgIATBRwktHASQCAiQJOMho4CQAwUcBJRgMnAQAmCjjJaOAkAMBEAScZDZwEAJgo4CSjgZMAABMFnGQ0cBIAYKKAk4wGTgIATBROq9U6OjpS/2INMAE4CQAwUWCdZDRwEgBgooh0EpZNJgAnAQAmikTrJPgpK+AkAMBEMVjsjskJlhoPcBIAYKI47fskbI4YKXASAGCiwB4Ho4GTAAATRfpO0v6/UMFwwEkAgIlihCODXpEAAAARSURBVOskvHw6PXASAGCi+H9eBQozSXW5hgAAAABJRU5ErkJggg==" alt="" />

2.修改wadcfgx文件,添加DataSources属性:

Cloudservie将LocalStroage中的内容通过WAD自动上传到BLOB中

3.添加上传到local storage的代码:

Index.cshtml

@{
ViewBag.Title = "Home Page";
}
<div class="jumbotron">
<h1>ASP.NET</h1>
<p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.</p>
<p><a href="http://asp.net" class="btn btn-primary btn-lg">Learn more &raquo;</a></p>
</div>
<div class="row">
<div class="col-md-12">
@using (Html.BeginForm("UploadZipFile", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<div class="form-group">
<label for="zipFile">Zip File</label>
<input type="file" id="zipFile" name="zipFile">
</div>
<button type="submit" class="btn btn-default">Submit</button>
}
</div>
</div>

对应的HomeController.cs实现如下:

        public ActionResult UploadZipFile(HttpPostedFileBase zipFile)
{
var localResource = RoleEnvironment.GetLocalResource("ZipFiles"); // Save zip file.
var localZipFilePath = Path.Combine(localResource.RootPath, zipFile.FileName);
zipFile.SaveAs(localZipFilePath); // Extract zip file to a random folder.
var localExtractedPath = Path.Combine(localResource.RootPath, Guid.NewGuid().ToString());
Directory.CreateDirectory(localExtractedPath);
System.IO.Compression.ZipFile.ExtractToDirectory(localZipFilePath, localExtractedPath); // Upload everything to blob storage.
foreach (var file in Directory.GetFiles(localExtractedPath, "*", SearchOption.AllDirectories))
{
// Upload to blob storage.
} return RedirectToAction("Index");
}

获取Local Storege的路径是:var localResource = RoleEnvironment.GetLocalResource("ZipFiles");

3.我在本地做了测试,通过代码上传到设置的Local Storage后,通过RDP登陆实例,会看到文件已经存在了,路径是C:\Resources\Directory\{部署ID}.WebRole1.ZipFiles

Cloudservie将LocalStroage中的内容通过WAD自动上传到BLOB中

4.一旦指定的Local Storage有了内容,对应的存储账号会生成容器wad-testcustom(这也是自己设置的名称),当日志自动上传成功后,会看到对应的存储账号容器中,上传了之前测试的文件:

Cloudservie将LocalStroage中的内容通过WAD自动上传到BLOB中

具体可以参考:http://blogs.msdn.com/b/davidhardin/archive/2011/03/31/configuring-diagnostics-wadcfg-to-capture-custom-log-files.aspx

关于Local Storage,就算不勾选"Clean on role recycle",在节点故障转移的时候,如果有的日志还没有及时存到BLOB中,我们还是会丢掉它们,具体可以参考:

http://justazure.com/microsoft-azure-cloud-services-part-3-service-package/

上一篇:java并发编程(四) 线程池 & 任务执行、终止源码分析


下一篇:php 中的信号处理