简体   繁体   中英

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. 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. 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? Currently, I have to login, and start the azure developmet storage manually, but once I log out, it shuts down. 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. Thanks!

Windows Azure Development Fabric will not run as Windows Service out-of-the box .

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 .

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:

[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.

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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