简体   繁体   English

作为Windows服务运行的Azure开发Storgare服务

[英]Azure development storgare service running as a windows service

I am working on a project that is a very large central media repository that uses Azure storage to house all of our external binaries that will be cosumed by 3rd party applications. 我正在一个项目上,该项目是一个非常大的中央媒体存储库,该存储库使用Azure存储来容纳我们的所有外部二进制文件,这些二进制文件将由第三方应用程序使用。 We have the app working with azure, but are now moving forward to adding a bunch of new features and the "develop and test from you local box" form of testing is no longer sufficient. 我们的应用程序正在使用azure,但现在正朝着添加一堆新功能的方向发展,而“从您的本地机器开发和测试”形式的测试已不再足够。 Since we have an array of external sources feed us media which needs to work in the cloud, we need a integration test environment setup. 由于我们有一系列外部资源向我们提供需要在云中工作的媒体,因此我们需要一个集成测试环境设置。 SO I have already set the environment up, the question I have is, is there a way to have the Azure development storage start and run as a windows service? 所以我已经设置好环境,我的问题是,有没有办法让Azure开发存储作为Windows服务启动和运行? Currently, I have to login, and start the azure developmet storage manually, but once I log out, it shuts down. 目前,我必须登录并手动启动azure developermet存储,但是一旦注销,它就会关闭。 This is not ideal, nor does it work. 这不是理想的方法,也不起作用。 Since this is a development box, and most of the data is junk, we don;t want to waste our space and bandwith sending this stuff to our azure account, which costs us money. 由于这是一个开发箱,并且大多数数据都是垃圾,因此我们不想浪费我们的空间,不要将这些东西发送到我们的azure帐户,这会花费我们很多钱。 Thanks! 谢谢!

Windows Azure Development Fabric will not run as Windows Service out-of-the box . Windows Azure Development Fabric无法作为Windows Service的即用型运行

The only way to keep actual service portable and capable of running in Console, WinService or Azure Worker is to design in such abstraction from the start . 使实际服务保持可移植性并能够在Console,WinService或Azure Worker中运行的唯一方法是从一开始就以这种抽象方式进行设计

Once you have proper abstractions, your cloud application becomes quite flexible. 一旦有了适当的抽象,您的云应用程序就会变得非常灵活。 For example you could even write unit tests like these: 例如,您甚至可以编写如下的单元测试:

[Test]
public void Test()
{
    Host.Initialize();
    Host.Start();
    var client = Host.Resolve<IMessageClient>();

    client.Send(new Hello {Word = "World"});
    client.Send(new Hello {Word = Rand.String.NextText(6000, 6000)});
    client.Send(new Bye {Word = "Earth"});
    SystemUtil.Sleep(50.Seconds());
    Host.Stop();
}

or if .NET 4.0 TPL is used: 或如果使用.NET 4.0 TPL:

[Test]
public void Test()
{

    using (var host = BuildHost())
    {
        host.Initialize();

        var client = host.Resolve<IMessageClient>();

        client.Send(new Hello { Word = "World" });
        client.Send(new Hello { Word = Rand.String.NextText(6000, 6000) });
        client.Send(new Bye { Word = "Earth" });

        using (var cts = new CancellationTokenSource())
        {
            var task = host.Start(cts.Token);
            SystemUtil.Sleep(10.Seconds());
            cts.Cancel(true);
            task.Wait(5.Seconds());
        }   
    }
}

similar wiring will be in the Console, WindowsService, Azure Host or mono daemon on Linux. 类似的接线将在Linux上的控制台,WindowsService,Azure主机或mono守护程序中进行。

And if you keep storage properly abstracted as well, then there will be no need to actually use Azure Storage (either development or production) for the tests, efficiently using local file storage or in-memory representations where it fits. 而且,如果您还对存储进行了适当的抽象,则将无需实际使用Azure存储(开发或生产)进行测试,从而可以有效地使用本地文件存储或适合的内存表示形式。

Basically, designing cloud architecture to be portable from the start, simplifies a lot of things down the road, reducing development and maintenance costs. 基本上,从一开始就将云架构设计为可移植的,可以简化很多事情,减少开发和维护成本。

NB: test snippets are taken from Lokad.CQRS for Windows Azure Guidance and Framework 注意:测试摘录来自Lokad.CQRS,适用于Windows Azure指导和框架

应该可以在具有足够权限的用户帐户下将主机作为计划任务运行。

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

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