Deploy and start the windowsservice program on windowsazure

Source: Internet
Author: User

 

Deploy and start the windowsservice program on windowsazure

 

After you have deployed a webrole on windowsazure, you find that as your usage increases, there will be a lot of invalid data in the database, so you plan to regularly Delete invalid data in the database. In this case, you need to deploy a small program on the azure Virtual Machine to implement this action. Of course, the small programs that implement this data deletion are diverse, and the deployment methods are also diverse, this article is just a virtual requirement to propose a method to deploy your own windowservice on windowsazure.

 

1. Add a windowsservice program to a webrole application.

For example, copy the compiled windowsservice program of agentservice.exe to the folder using a myappfolder, and add an installsvc. CMD file to install the program.

The content of the installsvc. CMD file is as follows:

% Windir % \ Microsoft. NET \ framework \ v4.0.30319 \ installutil.exe MyApp \ agentservice.exe

Net start agentservice

 

2. Set "Copy to output directory" for files in the MyApp folder to "Copy frequently ".

3. Start the windowsservice program.

Add a task to the. csdef file and use it to call the service installation script.

<?xml version="1.0" encoding="utf-8"?><ServiceDefinition name="WindowsAzureProject1" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">  <WebRole name="MvcWebRole1" vmsize="Small">    <Sites>      <Site name="Web">        <Bindings>          <Binding name="Endpoint1" endpointName="Endpoint1" />        </Bindings>      </Site>    </Sites>    <Endpoints>      <InputEndpoint name="Endpoint1" protocol="http" port="80" />    </Endpoints>    <Imports>      <Import moduleName="Diagnostics" />    </Imports>    <Startup>      <Task commandLine="MyApp\installsvc.cmd" executionContext="elevated" taskType="background" />    </Startup>  </WebRole></ServiceDefinition>

 

Now we can upload the webrole to windowsazure, and register and start our windowsservice program on the instance virtual machine of the role.

 

In addition, adding the following nodes to the azure role node can improve the execution permission of the role to solve some problems due to insufficient permissions.

  <WebRole name="MvcWebRole1" vmsize="Small">    <Runtime executionContext="elevated"></Runtime>  </WebRole>

 

References:

Http://blogs.msdn.com/ B /luispanzano/archive/2011/03/19/instalar-un-servicio-windows-en-azure.aspx

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.