Windows Azure的网站使用WebMatrix的3或类似的启动任务(不使用Visual Studio) [英] Windows Azure Website with a Startup task using Webmatrix 3 or similar (without using Visual Studio)

查看:161
本文介绍了Windows Azure的网站使用WebMatrix的3或类似的启动任务(不使用Visual Studio)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,Azure的网站制作得容易,不会有作用CONFIGS和这样的......但我还是想知道,是否有使用网站时,创建一个启动任务什么办法?
我这么问是因为我想通过FTP和WebMatrix中(不重新编译源,不使用Visual Studio),以缓解现有的网站的部署,然后用
启动任务部署和安装其它附加组件(水晶报表,的ActiveX DLL ...)
感谢您的答案
Mokh
PS:我的问题是这样的一个的复制和粘贴:与的Windows Azure网站启动任务

I know that Azure Websites are made to be easy, not have role configs and such...but I was still wondering, is there ANY way to create a Startup Task when using a Website? I'm asking because I would like to ease the deployment of an existing website through FTP and Webmatrix (not recompiling the source and without using Visual Studio), and then use Startup Task to deploy and install additionnal components (Crystal Reports, ActiveX Dll...) Thanks for answers Mokh PS : my question is an copy and paste of this one : Windows Azure Website with a Startup task

推荐答案

是的,有实现的功能相当于Windows Azure的网站云服务启动任务的方法不止一种。主要的区别和限制是您将不能运行使用提升的权限启动这些任务。

Yes, there is more than one way to implement functionality equivalent to Cloud Services startup tasks in Windows Azure Websites. The main difference and limitation is that you won't be able to run these startup tasks with elevated privileges.

这些做法采取的事实,即在Windows Azure中运行的网站Web应用程序可以生成过程和写入到磁盘的优势。他们甚至可能会导致可执行文件运行。

These approaches take advantage of the fact that the web applications running in Windows Azure Websites can spawn processes and write to disk. They can even cause executable files to run.

所以,你可以,例如,写一个ASP.NET应用程序,并在的Global.asax 的Application_Start 方法>运行,将安装在文件系统上的东西的批处理文件。正如 WebsiteStartupTask 样本项目展示,你可以写一个Global.asax文件这样执行任何命令:

So you can, for instance, write an ASP.NET application and use the Application_Start method in Global.asax to run a batch file that will install something on the file system. As demonstrated in the WebsiteStartupTask sample project, you could write a Global.asax file like this to execute any command:

<%@ Application Language="C#" %>

<script runat="server">

    void Application_Start(object sender, EventArgs e) 
    {
        string WindowsDir = Environment.GetEnvironmentVariable("windir");
        string command = System.IO.Path.Combine(WindowsDir, @"System32\cmd.exe");
        string outputFilePath = Server.MapPath("~/Log.txt");
        string arguments = String.Format("/c echo Startup task executed at {0} >>\"{1}\"", System.DateTime.UtcNow.ToString("o"), outputFilePath);
        System.Diagnostics.Process.Start(command, arguments);
    }
</script>

您也可以编写一个Web服务或HTTP端点,在接收到POST HTTP请求,会做同样的,所以你可以远程触发启动任务(甚至可能提交参数吧)

You could also write a web service or HTTP endpoint that, upon receiving a POST HTTP request, would do the same, so you could trigger your startup task remotely (possibly even submitting parameters to it).

在任何情况下,你可以在应用程序启动时做什么都会被你的应用程序运行在用户的安全权限的限制。您将无法执行任何需要管理员权限,但你可以执行,可以作为一个普通用户来执行任何东西。

In any case, what you can do at application startup will be limited by the security privileges of the user your application is running as. You won't be able to execute anything that requires administrator privileges, but you'll be able to execute anything that can be executed as a regular user.

这篇关于Windows Azure的网站使用WebMatrix的3或类似的启动任务(不使用Visual Studio)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆