简体   繁体   English

将文件复制到Azure WebRole上的输出目录

[英]Copy Files to the output directory on an Azure WebRole

We have an azure Webrole which we call as an API from other applications to convert webpages into a rendered byte array which we then attach as a pdf into emails. 我们有一个蔚蓝的Webrole,我们从其他应用程序中将其称为API,以将网页转换为呈现的字节数组,然后将其作为pdf附加到电子邮件中。 We do this using ABCpdf. 我们使用ABCpdf进行此操作。

For our latest project we have to use a second engine from ABC (ABCGecko) in order to render our pages correctly. 对于我们的最新项目,我们必须使用ABC的第二个引擎(ABCGecko)才能正确呈现页面。 The ABCGecko engine requires manually copying to the output directory after build occurs, it doesn't happen automatically. ABCGecko引擎需要在构建后手动复制到输出目录,但不会自动发生。

For a normal application this is no issue, I simply copy the required folder (XULRunner_38 for anyone who uses ABC) into the release after building but I can't figure out how to do this for an Azure WebRole and there doesn't seem to be anything much in the way of help from what I can see in google searches. 对于普通应用程序来说,这没问题,我只需要在构建后将所需的文件夹(对于使用ABC的任何人,将XULRunner_38文件夹)复制到发行版中,但是我不知道如何为Azure WebRole做到这一点,而且似乎也没有在Google搜索中可以看到的一切都可以为您提供帮助。

I'm assuming I either have to build the role and then adjust the package before I deploy, or deploy the role and then copy the folder across after. 我假设我必须先构建角色,然后在部署之前调整程序包,或者先部署角色,然后再复制文件夹。 I can't figure out how to do this though. 我不知道如何做到这一点。

If anyone has any ideas or has needed to manually copy files to an Azure Webrole in the past then I would greatly appreciate your help. 如果以前有任何想法或需要手动将文件复制到Azure Webrole的人,我们将非常感谢您的帮助。 Also I should mention that we use Visual Studio as our IDE and publish from within there in case that matters to anyone. 我还要提到,我们将Visual Studio用作我们的IDE,并在其中发布,以防对任何人都重要。

Azure web (and worker) roles allow you to define startup tasks, which allows you to call a script (eg powershell script, batch file) which can then perform actions such as copying files. Azure Web(和工作人员)角色允许您定义启动任务,该任务允许您调用脚本(例如,powershell脚本,批处理文件),然后可以执行诸如复制文件之类的操作。

Oh, and if you don't want it to attempt copying in the event a role instance reboots, you'd need to do something like leaving yourself a "breadcrumb" somewhere to signal that you've already done your init work. 哦,如果您不希望它在角色实例重新启动时尝试复制,则您需要执行一些操作,例如在某处放置“面包屑”以表明您已经完成了初始化工作。

What you don't want to ever do is manual copying of content to your role instances. 不需要做的是将内容手动复制到角色实例。 The moment those instances are updated (eg new Host OS update) or they're moved to another physical host, you'll lose any of the files you manually copied. 这些实例更新(例如,新的主机操作系统更新)或将它们移动到另一台物理主机时,您将丢失任何手动复制的文件。

This is all independent of any IDE (aside from general support for the script language you're writing in), since your startup task is going to execute on each web role instance when it starts up. 所有这些都独立于任何IDE(除了对您正在编写的脚本语言的一般支持),因为启动任务将在启动时在每个Web角色实例上执行。

More details about startup tasks are here . 有关启动任务的更多详细信息,请参见此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM