如何从启动任务访问Azure本地存储?
在我的 Azure 角色启动任务中,我需要部署本机 C++ 应用程序。我通过从 .cmd 文件运行一组操作来做到这一点。
问题是角色内容所在的 E:\ 驱动器以及运行启动任务的驱动器只有大约 1 GB 的可用空间,这不足以部署该应用程序。
我当然可以在服务定义中请求本地存储,但我找不到如何从启动任务中获取本地存储所在的实际路径 - 有 RoleEnvironment.GetLocalResource()
为此,但它似乎只能从角色代码中获得,我需要从启动任务内部执行相同的操作。
如何从启动任务中检测到本地存储的路径?
In my Azure role startup task I need to deploy my native C++ application. I do that by running a set of actions from a .cmd file.
The problem is that the E:\
drive where the role contents is located and from where the startup task is run only has about 1 gigabyte of free space and that's not enough for deploying that application.
I can of course ask for local storage in the service definition, but I can't find how to get the actual path of where the local storage will be located from the startup task - there's RoleEnvironment.GetLocalResource()
for that but it seems to only be available from the role code and I need to do the same from inside the startup task.
How do I detect the path to my local storage from a startup task?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如何从启动任务中检测到本地存储的路径?
在启动期间使用本地存储来存储文件
并且您可以从启动脚本中使用本地环境变量
PathToStartupStorage
、%PathToStartupStorage%
进行访问更多参考:http://msdn.microsoft.com/en-us/library/azure/hh974419.aspx
How do I detect the path to my local storage from a startup task?
Use Local Storage to Store Files During Startup
And you can access with local evironment variable
PathToStartupStorage
,%PathToStartupStorage%
from your startup scriptMore reference in: http://msdn.microsoft.com/en-us/library/azure/hh974419.aspx
如果我没记错的话,我们正在使用 Azure Bootstrapper。它很方便,如果您不熟悉 PowerShell,也不必处理它的复杂性。
目前我还不能 100% 确定,但我记得它也具有本地资源访问权限,因此您也许可以使用它。
If I recall correctly, we are using Azure Bootstrapper. It's convenient, and you don't have to deal with the complications of PowerShell if you aren't familiar with it.
I'm not 100% sure at this moment, but I remember it has local resource access as well, so you may be able to use it.
您可以编写 C# 或 PowerShell 来完成此操作。如今,我的首选方法是以下 PowerShell 脚本:
然后根据需要从批处理文件中调用该脚本:
编辑:另请参阅 http://blog.smarx.com/posts/using-a-local-storage-resource-from-a-startup-task,相同答案但在我的博客上。
You can write C# or PowerShell to do it. These days, my preferred method is the following PowerShell script:
which I then call from a batch file as needed:
EDIT: See also http://blog.smarx.com/posts/using-a-local-storage-resource-from-a-startup-task, the same answer but on my blog.