<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Distributed Development</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/mariok/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/mariok/feed.xml</link>
    <description>Thoughts on cloud, distributed computing &amp;amp; interoperability</description>
    <lastBuildDate>Tue, 16 Apr 2019 05:18:25 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Creating a Hadoop Development Cluster in Azure</title>
      <link>https://docs.microsoft.com/archive/blogs/mariok/creating-a-hadoop-development-cluster-in-azure</link>
      <pubDate>Fri, 12 Aug 2011 13:05:00 GMT</pubDate>
      <dc:creator><![CDATA[Mario Kosmiskas]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mariok/2011/08/12/creating-a-hadoop-development-cluster-in-azure/</guid>
      <description><![CDATA[In my previous post on Hadoop I showed how you could easily deploy a cluster to run on Azure. What...]]></description>
      <content:encoded><![CDATA[<p>In my <a href="http://blogs.msdn.com/b/mariok/archive/2011/05/11/hadoop-in-azure.aspx">previous post on Hadoop</a> I showed how you could easily deploy a cluster to run on Azure. What was missing was a way to efficiently use the cluster. You could always remote desktop to the Job Tracker and kick off a job but there are better ways.</p>
<p>This post is about actually using the cluster once it has been deployed to Azure. I chose the theme of a Development Cluster to justify making a few changes to how I previously configured the cluster and show some new techniques.</p>
<p>As a developer I expect easy access to the development cluster. The goal is to allow developers to safely connect to the cluster to deploy and debug their map/reduce jobs. SSH provides all the necessary tools for this &ndash; secure connection and tunneling. SSH not only allows developers to establish a secure session with the cluster in Azure but it also allows for full integration with IDEs making the typical development tasks a breeze.</p>
<p>I will be referring to two of my previous posts on <a href="http://blogs.msdn.com/b/mariok/archive/2011/05/11/hadoop-in-azure.aspx">Setting Up a Hadoop Cluster</a> and <a href="http://blogs.msdn.com/b/mariok/archive/2011/08/09/command-line-access-to-azure-vms-ssh.aspx">Configuring SSH</a>. It would be helpful to have them open as you follow the setup instructions below.</p>
<h2>The Development Cluster</h2>
<p>In this scenario of a development cluster I will use a single host to run both the Name Node and the Job Tracker. This is obviously not true for every development cluster but suffices for this demo. The number of slaves is initially set to 3. You can dynamically change the cluster size as I demonstrated in my previous post. If you are going to try it you might also want to adjust the VM size to meet your needs.</p>
<p>The procedure for deploying a Hadoop cluster has not changed. The dependencies are different though. First is the Hadoop version, I had previously used 0.21 which is not supported by many development tools since it&rsquo;s an unstable release. I reverted to the stable versions and ended up using 0.20.2. At the time of this writing 0.20.203.0rc1 was out but did not work on Windows. Cygwin needs the OpenSSH package installed to provide the SSH Windows Service (instructions in the SSH post). Finally is YAJSW. That didn&rsquo;t technically need to be updated, I just grabbed the latest drop for which is Beta-10.8.</p>
<p>Just follow the instructions from my previous post using the updated dependencies and grab this <a href="http://cid-76556b7fc951f312.office.live.com/self.aspx/Public/hadoop/dev/cluster-config.zip">cluster configuration template</a> and this <a href="http://cid-76556b7fc951f312.office.live.com/self.aspx/Public/hadoop/dev/HadoopDevClusterAzure.zip">Visual Studio 2010 project</a> instead. You should have the following files in a container in your storage account:</p>
<p align="center"><br />&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/1581.1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-40/1581.1.png"><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/1581.1.png" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-40/1581.1.png" width="238" height="114" /></a>&nbsp;&nbsp;<br />&nbsp;&nbsp;</p>
<p>You should be able to deploy your development cluster by publishing the HadoopAzure project directly from Visual Studio.</p>
<h2>Connecting to the Cluster</h2>
<p>A developer needs to connect to the cluster using SSH. I demonstrated how to do that using PuTTY, the only difference here is that we will need to setup a couple of tunnels. This screen shows the two tunnels required to access the Name Node and Job Tracker.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/5023.2.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-40/5023.2.png"><img style="margin-right: auto; margin-left: auto; display: block;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/5023.2.png" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-40/5023.2.png" width="329" height="326" /></a><br />Once you connect and login you can minimize the PuTTY window. We won&rsquo;t be using it but it must be open for the tunnels to remain open.</p>
<h2>Accessing the Cluster</h2>
<p>With the tunnels open to the development cluster you can use it as if it was local.</p>]]></content:encoded>
    </item>
    <item>
      <title>Command Line Access to Azure VMs – SSH</title>
      <link>https://docs.microsoft.com/archive/blogs/mariok/command-line-access-to-azure-vms-ssh</link>
      <pubDate>Tue, 09 Aug 2011 14:25:00 GMT</pubDate>
      <dc:creator><![CDATA[Mario Kosmiskas]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mariok/2011/08/09/command-line-access-to-azure-vms-ssh/</guid>
      <description><![CDATA[In a previous post I showed how to configure a service to allow for  remote access using PowerShell...]]></description>
      <content:encoded><![CDATA[<p>In a previous post I showed how to configure a service to allow for <a href="http://blogs.msdn.com/b/mariok/archive/2011/08/08/command-line-access-to-azure-vms-powershell-remoting.aspx"> remote access using PowerShell Remoting</a>. Another way of achieving the same goal is to use SSH.</p>
<p>SSH is capable of more than just remote access &ndash; copying files and tunneling are a few of the extra features. I&rsquo;ll show how to get a SSH daemon working and how to connect to it for a remote session. I haven&rsquo;t tested other features, let me know if you try anything else.</p>
<h2>Cygwin</h2>
<p>There are many SSH servers available for Windows. I will use the OpenSSH from Cygwin in this post.</p>
<p>The first task is to install Cygwin. It&rsquo;s better to install it locally and package Cygwin in the Azure deployment package or create a zip file of the local installation and upload it to your Azure Storage account. The only extra package required is &ldquo;openssh&rdquo;.</p>
<p><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/2746.1.png" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-40/2746.1.png" width="445" height="323" /></p>
<h2>Role Configuration</h2>
<p>There are a few steps to configure a role to run the SSH service. I&rsquo;ll describe only the main ones here, refer to the sample project at the bottom of the post for a complete working example.</p>
<h3>1.&nbsp;Endpoint</h3>
<p>The default SSH port is 22 hence the role must define the following endpoint:</p>
<pre>  &lt;Endpoints&gt;
    &lt;InputEndpoint name="SSH" protocol="tcp" port="22" localPort="22" /&gt;
  &lt;/Endpoints&gt;
</pre>
<h3>2.&nbsp;Create a user</h3>
<p>You need an account to log in via SSH. Since this account will also be used to run the SSH Windows Service it must be in the Administrators Group.</p>
<pre>  net user &lt;username&gt; &lt;password&gt; /add
  net localgroup Administrators &lt;username&gt; /add
</pre>
<h3>3.&nbsp;Grant Privileges</h3>
<p>The user account you created must have the required privileges to be used by a Windows Service. I used <span style="font-family: courier new,courier;">ntright.exe</span><sup><a href="#ref2">[2]</a></sup> for granting the <span style="color: #0000ff; font-family: courier new,courier;">SeServiceLogonRight</span> privilege.</p>
<h3>4.&nbsp;Fix Unix File Permissions</h3>
<p>Because Cygwin was copied to the VM instead of installed the Unix permissions for a few critical files must be fixed. This must be done from within Cygwin via a script.</p>
<h3>5.&nbsp;Add the New User to Cygwin</h3>
<p>The user account you previously created must be added to the Cygwin users list. Once again this must be done from the Cygwin environment.</p>
<h3>6.&nbsp;Create and Start the Service</h3>
<p>Cygwin includes a script to configure SSH as a Windows Service - <span style="font-family: courier new,courier;">ssh-host-config</span>. After running this script a new service will be available and can be started the regular way or using the <span style="font-family: courier new,courier;">cygrunsrv</span> command from Cygwin. These commands must be run using the account created in step 2 <a href="#ref1"><sup>[1]</sup></a>.</p>
<h2>Remote Access</h2>
<p>With the SSH enabled service deployed it&rsquo;s time to connect to it. Using PuTTY simply enter the DNS name of your deployment in the Host Name field:</p>
<p><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/0131.2.png" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-40/0131.2.png" width="394" height="394" /></p>
<p>And if you want to avoid being disconnected because of timeouts you can set PuTTY to keep a heartbeat using any value under 60 seconds:</p>
<p><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/8308.3.png" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-40/8308.3.png" width="399" height="391" /></p>
<p>Then opening a connection will get you access to the VM:</p>
<p><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/8688.4.png" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-40/8688.4.png" /></p>
<p>SSH will actually allow you to connect to a service with multiple instances. You will not be able to specify the exact instance though, every new connection will be established to any one of the instances in the service.</p>
<h2>Sample Project</h2>
<p>This project creates a&nbsp;service with SSH enabled. It&nbsp;expects to find a&nbsp;zip file called <span style="font-family: courier new,courier;">cygwin.zip</span> in your&nbsp;storage account.&nbsp;The zip file should contain the Cygwin install directory (e.g. C:\Cygwin).</p>
<p>Before you publish the project you must edit the <span style="font-family: courier new,courier;">EnableSSH.cmd</span> and <span style="font-family: courier new,courier;">startSSH.sh</span> files and enter the new username and password at the top of both files. There was no easy way to share that information between the Windows batch and the Shell script so it must be entered twice. You must also edit the DownloadBlob.ps1 file and enter your storage account information in the second to last line. You will also need to enter the container name in the same line.</p>
<p><iframe style="width: 98px; height: 115px; padding: 0; background-color: #fcfcfc;" title="Preview" marginheight="0" src="https://skydrive.live.com/embedicon.aspx/Public/RemoteAccessSSH/RemoteAccessSSH.zip?cid=76556b7fc951f312&amp;sc=documents" frameborder="0" marginwidth="0" scrolling="no"></iframe></p>
<h2>References</h2>
<ol>
<li><a name="ref1"></a><a href="http://www.davidaiken.com/2011/01/19/running-azure-startup-tasks-as-a-real-user/">Running Azure startup tasks as a real user</a></li>
<li><a name="ref2"></a><a href="http://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;id=17657">Windows Server 2003 Resource Kit Tools</a></li>
</ol>]]></content:encoded>
    </item>
    <item>
      <title>Command Line Access to Azure VMs – PowerShell Remoting</title>
      <link>https://docs.microsoft.com/archive/blogs/mariok/command-line-access-to-azure-vms-powershell-remoting</link>
      <pubDate>Mon, 08 Aug 2011 17:28:00 GMT</pubDate>
      <dc:creator><![CDATA[Mario Kosmiskas]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mariok/2011/08/08/command-line-access-to-azure-vms-powershell-remoting/</guid>
      <description><![CDATA[Every so often I deploy a service to Azure which requires some sort of manual intervention during...]]></description>
      <content:encoded><![CDATA[<p>Every so often I deploy a service to Azure which requires some sort of manual intervention during its execution. That typically involves issuing a few commands from the machine hosting the service or maybe even updating configuration files. The regular way to do this is to setup Remote Desktop on the service and connect to the VM just to open a command line window to issue the required command(s).</p>
<p>Although that is a fine solution it would be nice to be able to issue remote commands from my local machine.</p>
<p>Turns out you can do exactly that using PowerShell Remoting.I am not going to cover the details of PowerShell Remoting in this post, I&rsquo;ll just show the configuration needed to make it work for the simple case. PowerShell Remoting is very flexible, I encourage you to read more about it if you are not familiar with all it can do.</p>
<h2>Prerequisite</h2>
<p>You need a user account to remote access a VM. When you configure Remote Desktop an account is automatically created for you. Since we are not going to use Remote Desktop we need to create an account manually and because the setup steps require an Administrator account we will &nbsp;add it to the Administrator&rsquo;s group.</p>
<p>An account can be created with these two commands. Simply run them as part of a startup task with elevated privileges.</p>
<pre>net user &lt;username&gt; &lt;password&gt; /add
net localgroup Administrators &lt;username&gt; /add
</pre>
<h2>Configuration</h2>
<p>PowerShell Remoting needs the correct network configuration to allow for remote connectivity. Since we will be accessing the VM over the web we are required to use HTTPS to secure the communication channel. Skipping over the details of Windows Remote Management which is used by PowerShell Remoting, I will just say the default HTTPS port is 5986.</p>
<p>To allow connectivity to the VM this endpoint must be added to the ServiceDefinition.csdef:</p>
<pre class="html"> 
&lt;endpoints&gt; 
  &lt;inputendpoint localport="5986" port="5986" protocol="tcp" name="WinRM" /&gt; 
&lt;/endpoints&gt; 
</pre>
<p>With the proper port open it is just a matter of enabling PowerShell Remoting. Two issues need to be resolved before enabling it.</p>
<p>The first is using the correct user account to setup Remoting. You must use the account previously created to run the script to setup Remoting<a href="#ref1"><sup>[1]</sup></a>. With these commands the user you previously created will execute the script e:\approot\StartRemotingListener.ps1:</p>
<pre>schtasks /CREATE /TN "StartRemotingListener" /SC ONCE /SD 01/01/2020 /ST 00:00:00 
              /RL HIGHEST /RU &lt;username&gt; /RP &lt;password&gt; 
              /TR "powershell -ExecutionPolicy unrestricted 
                              -Command e:\approot\StartRemotingListener.ps1 -Force" /F
schtasks /RUN /TN "StartRemotingListener"
</pre>
<p>The second issue is configuring the certificate needed for the HTTPS connection. Acquiring a certificate might not be a problem for a production environment. You might already have one for your service and could reuse it. It can be a problem if your service doesn&rsquo;t require a certificate for normal operation or for non-production environments.</p>
<p>Fortunately it is possible to generate a certificate using a PowerShell script<a href="#ref2"><sup>[2]</sup></a>. This script generates a certificate associated with the hostname of the VM. If you are going to use this script in production you should change $certId the fully qualified URL of your service.</p>
<pre>function Create-Certificate($hostname) {
	$name = new-object -com "X509Enrollment.CX500DistinguishedName.1"
	$name.Encode("CN=$hostname", 0)
 
	$key = new-object -com "X509Enrollment.CX509PrivateKey.1"
	$key.ProviderName = "Microsoft RSA SChannel Cryptographic Provider"
	$key.KeySpec = 1
	$key.Length = 1024
	$key.SecurityDescriptor = 
                 "D:PAI(A;;0xd01f01ff;;;SY)(A;;0xd01f01ff;;;BA)(A;;0x80120089;;;NS)"
	$key.MachineContext = 1
	$key.Create()
 
	$serverauthoid = new-object -com "X509Enrollment.CObjectId.1"
	$serverauthoid.InitializeFromValue("1.3.6.1.5.5.7.3.1")
	$ekuoids = new-object -com "X509Enrollment.CObjectIds.1"
	$ekuoids.add($serverauthoid)
	$ekuext = new-object -com "X509Enrollment.CX509ExtensionEnhancedKeyUsage.1"
	$ekuext.InitializeEncode($ekuoids)
 
	$cert = new-object -com "X509Enrollment.CX509CertificateRequestCertificate.1"
	$cert.InitializeFromPrivateKey(2, $key, "")
	$cert.Subject = $name
	$cert.Issuer = $cert.Subject
	$cert.NotBefore = get-date
	$cert.NotAfter = $cert.NotBefore.AddDays(180)
	$cert.X509Extensions.Add($ekuext)
	$cert.Encode()
 
	$enrollment = new-object -com "X509Enrollment.CX509Enrollment.1"
	$enrollment.InitializeFromRequest($cert)
	$certdata = $enrollment.CreateRequest(0)
	$enrollment.InstallResponse(2, $certdata, 0, "")
}
 
function Find-Certificate($hostname) {
	foreach ($cert in Get-ChildItem cert:\LocalMachine\My) { 
		if ($cert.Subject -eq ("CN=" + $hostname)) {
			return $cert
		}
	}
}
 
# Using the machine name - ok for staging deployments
# In a production environment this should be set to the public URL
$certId = $env:computername

Create-Certificate $certId
$cert = Find-Certificate $certId

winrm create winrm/config/listener?Address=*+Transport=HTTPS 
      `@`{Hostname=`"($certId)`"`;CertificateThumbprint=`"($cert.Thumbprint)`"`}

Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 2000
</pre>
<p>After you deploy a service you can use any of the remoting enabled cmdlets or start a remote session using:</p>
<pre>Enter-PSSession -ConnectionUri https://&lt;service id&gt;.cloudapp.net:5986 
                     -Credential $cred -SessionOption (New-PSSessionOption -SkipCACheck 
                     -SkipCNCheck -SkipRevocationCheck) -Authentication Negotiate
</pre>
<p>You should then be connected to the VM and able to run any command on the remote machine.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/4101.commandwindow.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-40/4101.commandwindow.png"><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/4101.commandwindow.png" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-40/4101.commandwindow.png" /></a>&nbsp;</p>
<h3>Limitations</h3>
<p>This method will only allow connections to services with a single instance because there is no way to target a specific VM in a service. This limitation probably means this technique is mostly useful for non-production services.</p>
<p>Another problem that might affect you are timeouts. Azure will close inactive connections after a period of time. If you leave your PowerShell window inactive too long you will need to reconnect.</p>
<h2>Sample Project</h2>
<p>You can download this project to see it all working. Before you publish it you will need to edit the <span style="font-family: courier new,courier;">EnablePSRemoting.cmd</span> file and add a username and password in the first two lines. Make sure the password is complex enough otherwise the user creation will fail.</p>
<p><iframe style="width: 98px; height: 115px; padding: 0; background-color: #fcfcfc;" title="Preview" marginheight="0" src="https://skydrive.live.com/embedicon.aspx/Public/RemoteAccess/RemoteAccess.zip?cid=76556b7fc951f312&amp;sc=documents" frameborder="0" marginwidth="0" scrolling="no"></iframe></p>
<h2>References</h2>
<ol>
<li><a name="ref1"></a><a href="http://www.davidaiken.com/2011/01/19/running-azure-startup-tasks-as-a-real-user/">Running Azure startup tasks as a real user</a></li>
<li><a name="ref2"></a><a href="http://blogs.technet.com/b/vishalagarwal/archive/2009/08/22/generating-a-certificate-self-signed-using-powershell-and-certenroll-interfaces.aspx">Generating a certificate (self-signed) using powershell and CertEnroll interfaces</a></li>
</ol>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Hadoop in Azure</title>
      <link>https://docs.microsoft.com/archive/blogs/mariok/hadoop-in-azure</link>
      <pubDate>Wed, 11 May 2011 11:00:00 GMT</pubDate>
      <dc:creator><![CDATA[Mario Kosmiskas]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mariok/2011/05/11/hadoop-in-azure/</guid>
      <description><![CDATA[Is it possible to deploy a Hadoop cluster in Azure? It sure is and setting one up is not difficult,...]]></description>
      <content:encoded><![CDATA[<p>Is it possible to deploy a Hadoop cluster in Azure? It sure is and setting one up is not difficult, here&rsquo;s how you do it.</p>
<table style="border-width: 0px; border-color: #339966; width: 80%; background-color: #dcdcdc;" border="0">
<tbody>
<tr>
<td>
<p><strong>Update</strong>: Microsoft has recently announced a new 'Big Data' strategy and&nbsp;Hadoop is an integral part of it. Microsoft will provide an optimized experience for Hadoop running on Azure and on Windows Servers.</p>
<p>Read the <a href="http://blogs.technet.com/b/microsoft_blog/archive/2011/10/12/microsoft-expands-data-platform-to-help-customers-manage-the-new-currency-of-the-cloud.aspx" target="_blank">official announcement</a> for more information. This <a href="http://blogs.technet.com/b/port25/archive/2011/10/11/microsoft-hadoop-and-big-data.aspx" target="_blank">blog post</a> has more information on the Hadoop announcement.</p>
</td>
</tr>
</tbody>
</table>
<p>In this post I will demonstrate how to create a typical cluster with a Name Node, a Job Tracker and a customizable number of Slaves. You will also be able to dynamically change the number of Slaves using the Azure Management Portal. I will save the explanation of the mechanics for another post.</p>
<p>Follow these steps to create an Azure package for your Hadoop cluster:</p>
<h3>Download all dependencies</h3>
<ul>
<li>This <a href="http://cid-76556b7fc951f312.office.live.com/self.aspx/Public/hadoop/HadoopAzure.zip">Visual Studio 2010 project</a> is pre-configured with Roles for each Hadoop component. Don&rsquo;t worry if you don&rsquo;t have Visual Studio or don&rsquo;t want to <a href="http://www.microsoft.com/express/Downloads/">install the express edition</a>, you can do everything from the command line.</li>
<li>The <a href="http://cid-76556b7fc951f312.office.live.com/self.aspx/Public/hadoop/cluster-config.zip">cluster configuration templates</a>.</li>
<li>Install the latest <a href="http://www.microsoft.com/windowsazure/sdk/">Azure SDK</a>. As of this writing the latest version was 1.4.</li>
<li>The <a href="http://www.apache.org/dyn/closer.cgi/hadoop/core/">Hadoop binaries</a>. &nbsp;I used version 0.21. Hadoop is distributed in a tar.gz file, you will need to convert it to a ZIP file. You can use <a href="http://7-zip.org/">7-zip</a> for the task.</li>
<li>Now <a href="http://cygwin.com/setup.exe">install Cygwin</a> and package it in a single ZIP file. Hadoop 0.21 requires Cygwin under Windows. It&rsquo;s fine if you don&rsquo;t know anything about it, Hadoop uses it behind the scenes so you won&rsquo;t need to even launch it. There is an on-going effort to <a href="https://issues.apache.org/jira/browse/HADOOP-6767">remove this dependency</a> for Hadoop 0.22 but it&rsquo;s not ready yet. Just run the Cygwin install and accept all defaults. You should end up with Cygwin installed in <span style="font-family: courier new,courier;">c:\cygwin</span>. Create a compressed folder of <span style="font-family: courier new,courier;">c:\cygwin </span>called <span style="font-family: courier new,courier;">cygwin.zip</span>.</li>
<li>Download the latest version of <a href="http://sourceforge.net/projects/yajsw/files/">Yet Another Java Service Wrapper</a>. Beta-10.6 was the current version as of this writing.</li>
<li>The last dependency is a Java VM to host Hadoop and YAJSW. If you don&rsquo;t want to update any of the configuration files in this guide you will need to bundle your favorite JVM in a zip file called <span style="font-family: courier new,courier;">jdk.zip</span>. All JVM files must be in a folder also called jvm in the ZIP file. If you have your JVM installed under <span style="font-family: courier new,courier;">C:\Program Files\Java\jdk1.6.0_&lt;revision&gt;\</span> you will need to rename (or copy) the <span style="font-family: courier new,courier;">jdk1.6.0_&lt;revision&gt;</span> folder to <span style="font-family: courier new,courier;">jdk</span> and zip it.</li>
</ul>
<h3>Configure your cluster</h3>
<p>The <span style="font-family: courier new,courier;">custer-config.zip</span> you downloaded has all the files needed to configure your Hadoop cluster. You will find the familiar <span style="font-family: courier new,courier;">[core|hdfs|mapred]-site.xml </span>files there. Ignore all other files for now, I&rsquo;ll explain what they are for in a later post. Edit the <span style="font-family: courier new,courier;">*-site.xml </span>files as needed for your cluster configuration. Make sure to only add and not change any of the properties.</p>
<p>Create a new <span style="font-family: courier new,courier;">cluster-config.zip </span>if you updated any for the XML files.</p>
<h3>Upload all dependencies to your Azure Storage account</h3>
<p>Create a container called <span style="font-family: courier new,courier;">bin </span>and upload all zip files to it. Use your favorite tool for the job, I like <a href="http://clumsyleaf.com/products/cloudxplorer">ClumsyLeaf&rsquo;s CloudXplorer</a>. You should end up with these files in the <span style="font-family: courier new,courier;">bin</span> container</p>
<p align="center">&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/3716.1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-40/3716.1.png"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/3716.1.png" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-40/3716.1.png" width="260" height="123" /></a></p>
<h3>Configure your Azure Deployment</h3>
<p>Unzip the Visual Studio 2010 project. You can either use Visual Studio from here or update the required files using any text editor. I included a batch file to package the deployment if you are going down the command line route.</p>
<p>If you are using Visual Studio the only file you must change is <span style="font-family: courier new,courier;">NameNode\SetEnvironment.cmd</span>. The projects that require this file have links to it. If you are not using Visual Studio you have to change it in three other places <span style="font-family: courier new,courier;">NameNode\bin\Debug</span>, <span style="font-family: courier new,courier;">JobTracker\bin\Debug</span> and <span style="font-family: courier new,courier;">NameNode\bin\Debug</span>. Get an access key from your storage account and construct a connection string then paste it in the first line replacing <span style="font-family: courier new,courier;">[your connection string]</span>. An Azure connection string has this format:</p>
<p style="padding-left: 30px;"><span style="font-family: courier new,courier;">DefaultEndpointsProtocol=http;AccountName=[your_account_name];AccountKey=[key]</span></p>
<p>&nbsp;Unless you used different versions of any of the dependencies you won&rsquo;t need to change anything else.</p>
<p>The Azure deployment is set to use 1 large VM for the Name Node, 1 large VM for the Job Tracker and 4 Extra Large nodes as Slaves. If you are ok with that configuration skip to the next step. If you like anything different change the Roles configuration directly in Visual Studio or edit both the <span style="font-family: courier new,courier;">HadoopAzure\ServiceDefinition.csdef</span> and <span style="font-family: courier new,courier;">HadoopAzure\ServiceConfiguration.cscfg</span> to the desired VM sizes and count.</p>
<h3>Deploy your cluster</h3>
<p>Create a new service to host your Hadoop cluster. The project is pre-configured for remote access to the machines in the cluster. If you didn&rsquo;t change the project configuration you will need to upload the certificate <span style="font-family: courier new,courier;">AzureHadoop.pfx</span> in the root of the project to your service. The certificate password is <span style="color: #3366ff;"><b>hadoop</b></span>. The deployment will fail if you don&rsquo;t have this certificate.</p>
<p>If you are using Visual Studio 2010 you can deploy by right-clicking on the Cloud project and selecting <i>deploy</i>. If you are not just run the <span style="font-family: courier new,courier;">buildPackage.cmd</span> from the root of the project using a <i>Windows Azure SDK Command Prompt</i>. You will get the Azure package <span style="font-family: courier new,courier;">Hadoop.cspkg</span> to deploy using the Azure Management Portal.</p>
<p>Deploy your service (you can ignore the warning message). Wait for it to complete, you should see something like this:</p>
<p>&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/3108.2.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-40/3108.2.png"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/3108.2.png" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-40/3108.2.png" /></a></p>
<h2>Using your Hadoop cluster</h2>
<p>Now that everything is up and running you can navigate to the Name Node Summary page. The URL is <span style="font-family: courier new,courier;">http://&lt;your service name&gt;.cloudapp.net:50070</span>.</p>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/5314.3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-40/5314.3.png"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/5314.3.png" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-40/5314.3.png" /></a></p>
<p>If you click on &ldquo;Browse the filesystem&rdquo; Hadoop will construct a URL with the IP address of one of the Slaves. That IP address is not accessible from the Internet so you will need to replace it in the URL with <span style="font-family: courier new,courier;">&lt;your service name&gt;.cloudapp.net</span> and you will be able to browse the file system:</p>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/1157.4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-40/1157.4.png"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/1157.4.png" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-40/1157.4.png" /></a></p>
<p>Let&rsquo;s run one of the example jobs Hadoop provides to confirm the cluster is working. As it is configured right now you must log in to the Job Tracker to start a new job. I will present alternatives in a future post (<i>hint Azure Connect</i>).</p>
<p>Go back to the Azure Management Portal and RDP into the Job Tracker by selecting it and clicking &ldquo;Connect&rdquo; in the toolbar. The username is <strong><span style="color: #3366ff;">hadoop</span></strong> and the password is <strong><span style="color: #3366ff;">H1Doop</span></strong>. After you log in open a command prompt window and execute the following commands:</p>
<p><span style="font-family: courier new,courier;">E:\AppRoot\SetEnvironment.cmd</span></p>
<p><span style="font-family: courier new,courier;">cd /d %HADOOP_HOME%</span></p>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/3821.5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-40/3821.5.png"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/3821.5.png" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-40/3821.5.png" /></a></p>
<p>Now you are ready to run a job. I put together a hadoop script so you don&rsquo;t have to deal with Cygwin for launching jobs. The syntax is the same as the regular hadoop scripts. Let&rsquo;s launch a small job:</p>
<p style="padding-left: 30px;"><span style="font-family: courier new,courier;">bin\hadoop jar hadoop-mapred-examples-0.21.0.jar pi 20 200</span></p>
<p>If you navigate to the Job Tracker page you will see the job running. The URL is <span style="font-family: courier new,courier;">http://&lt;your service name&gt;.cloudapp.net:50030</span>.</p>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/5516.6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-40/5516.6.png"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/5516.6.png" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-40/5516.6.png" /></a></p>
<p>Congratulations, you just ran your first Hadoop job in Azure!</p>
<h2>What can I do with my Hadoop cluster?</h2>
<p>The cluster is fully operational. You can run any job you would like. You can also use the Azure Management Portal to dynamically change the number of Slaves. Hadoop will discover the new node(s) or find out nodes were removed and reconfigure the cluster accordingly.</p>
<p>I added an extra Slave node</p>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/2376.7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-40/2376.7.png"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/2376.7.png" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-40/2376.7.png" width="422" height="264" /></a></p>
<p>And my cluster changed to</p>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/2746.8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-40/2746.8.png"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/2746.8.png" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-40/2746.8.png" /></a></p>
<p>If you used Hadoop in production you know you must take extra steps to prepare the Name Node, mostly around high availability. That&rsquo;s a topic in itself which I plan to discuss in another post. If you can&rsquo;t wait and want setup a backup and/or a checkpoint node go ahead, that&rsquo;s certainly part of the solution. Azure Drive is probably another piece.</p>
<p>Let me know your experiences using Hadoop in Azure.</p>]]></content:encoded>
    </item>
    <item>
      <title>Sharing Folders in Azure</title>
      <link>https://docs.microsoft.com/archive/blogs/mariok/sharing-folders-in-azure</link>
      <pubDate>Fri, 11 Feb 2011 14:50:00 GMT</pubDate>
      <dc:creator><![CDATA[Mario Kosmiskas]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mariok/2011/02/11/sharing-folders-in-azure/</guid>
      <description><![CDATA[When multiple instances of an application need to share data in Azure they typically use Azure...]]></description>
      <content:encoded><![CDATA[<p>When multiple instances of an application need to share data in Azure they typically use Azure Storage or SQL Azure. Some legacy applications were written to use Shared Folders to exchange information between instances or in producer/consumer scenarios. Porting these applications to Azure present a challenge since Azure doesn&rsquo;t natively support Shared Folders.</p>
<p>One option is to rewrite parts of the legacy application to directly use Azure Storage instead of Shared Folders. This is the ideal way of migrating an application to the cloud. Your application will get all benefits of cloud storage, such as <em>infinite</em> storage and automatic replication, but more importantly I/O will be distributed in the cloud which can give some applications a significant performance boost.</p>
<p>Rewriting legacy applications is not always possible. You can still move these legacy applications to the cloud as-is but it requires some understanding of Azure to setup the environment correctly.</p>
<h2>Enabling Shared Folders</h2>
<p>The default Azure environment is locked down to reduce security exposure of each role. A role can only use the ports specified in the role definition, and that includes the ports needed for Shared Folders to work. The first step in enabling Shared Folders is to define two internal endpoints:</p>
<p class="MsoNormal"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span style="mso-spacerun: yes;"><span style="font-size: 9.5pt;">&nbsp;</span></span></span></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span style="mso-spacerun: yes;"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 9.5pt;">&lt;</span></span></span><span style="font-size: 9.5pt;"><span><span style="color: #a31515;">Endpoints</span></span></span><span><span style="color: #0000ff; font-size: 9.5pt;">&gt;</span></span></span><span>&nbsp;</span></p>
<p class="MsoNormal"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span style="mso-spacerun: yes;"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 9.5pt;">&lt;</span></span></span><span style="font-size: 9.5pt;"><span><span style="color: #a31515;">InternalEndpoint</span></span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">name</span></span><span><span style="color: #0000ff;">=</span></span></span><span><span style="font-size: 9.5pt;"><span style="color: #000000;">"</span><span><span style="color: #0000ff;">NetBIOSSession</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">protocol</span></span><span><span style="color: #0000ff;">=</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">tcp</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">port</span></span><span><span style="color: #0000ff;">=</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">139</span></span><span style="color: #000000;">"</span></span><span><span style="color: #0000ff; font-size: 9.5pt;"> /&gt;</span></span></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span style="mso-spacerun: yes;"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 9.5pt;">&lt;</span></span></span><span style="font-size: 9.5pt;"><span><span style="color: #a31515;">InternalEndpoint</span></span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">name</span></span><span><span style="color: #0000ff;">=</span></span></span><span><span style="font-size: 9.5pt;"><span style="color: #000000;">"</span><span><span style="color: #0000ff;">SMB</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">protocol</span></span><span><span style="color: #0000ff;">=</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">tcp</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">port</span></span><span><span style="color: #0000ff;">=</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">445</span></span><span style="color: #000000;">"</span></span><span><span style="color: #0000ff; font-size: 9.5pt;"> /&gt;</span></span></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span style="mso-spacerun: yes;"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 9.5pt;">&lt;/</span></span></span><span style="font-size: 9.5pt;"><span><span style="color: #a31515;">Endpoints</span></span></span><span><span style="color: #0000ff; font-size: 9.5pt;">&gt;</span></span></span></p>
<p>
<p>Keep in mind there is a limit to the number of endpoints a role can define. Currently a single role can define up to 5 endpoints.</p>
<p>Defining the required endpoints is not enough for SMB to work properly. The firewall must also be configured to enable file sharing. It can be done with this command:</p>
<p class="MsoNormal"><span><span style="font-family: Consolas;"><span style="color: #000000; font-size: 9.5pt;">&nbsp;</span></span></span></p>
<p class="MsoNormal"><span><span style="font-family: Consolas;"><span style="color: #000000; font-size: 9.5pt;">netsh firewall set service type=fileandprint mode=enable profile=Current</span></span></span></p>
<p>
<p>These changes will allow SMB between roles but sharing folders will not be possible yet. The reason is the user account roles execute as &ndash; the SYSTEM account. Because your role is running under SYSTEM a new account must be created for all shared folder operations. You can use any programmatic way of creating an account, I like to use PowerShell for this purpose. The following script creates an account, it uses two variables set elsewhere $netuser and $password, for the account name and password, respectively.</p>
<p class="MsoNormal"><span style="mso-themecolor: accent3; mso-themeshade: 191; mso-style-textfill-fill-color: #77933c; mso-style-textfill-fill-themecolor: accent3; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-colortransforms: lumm=75000;"><span style="font-family: Consolas;"><span style="color: #77933c; font-size: 9.5pt;">&nbsp;</span></span></span></p>
<p class="MsoNormal"><span style="mso-themecolor: accent3; mso-themeshade: 191; mso-style-textfill-fill-color: #77933c; mso-style-textfill-fill-themecolor: accent3; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-colortransforms: lumm=75000;"><span style="font-family: Consolas;"><span style="color: #77933c; font-size: 9.5pt;"># Create a user to manage shared folders</span></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas;"><span><span style="color: #c00000;"><span style="font-size: 9.5pt;">$server </span></span></span><span><span style="font-size: 9.5pt;"><span style="color: #000000;">= </span><span style="mso-themecolor: background2; mso-themeshade: 64; mso-style-textfill-fill-color: #4a452a; mso-style-textfill-fill-themecolor: background2; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-colortransforms: lumm=25000;"><span style="color: #4a452a;">"WinNT://" </span></span><span style="color: #000000;">+ </span><span><span style="color: #c00000;">$env:</span></span><span style="color: #000000;">computername + </span></span><span style="mso-themecolor: background2; mso-themeshade: 64; mso-style-textfill-fill-color: #4a452a; mso-style-textfill-fill-themecolor: background2; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-colortransforms: lumm=25000;"><span style="color: #4a452a; font-size: 9.5pt;">",computer"</span></span></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas;"><span><span style="color: #c00000;"><span style="font-size: 9.5pt;">$computer </span></span></span><span><span style="font-size: 9.5pt;"><span style="color: #000000;">= </span><span style="mso-themecolor: accent3; mso-themeshade: 128; mso-style-textfill-fill-color: #4f6228; mso-style-textfill-fill-themecolor: accent3; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-colortransforms: lumm=50000;"><span style="color: #4f6228;">[ADSI] </span></span></span><span><span style="color: #c00000; font-size: 9.5pt;">$server</span></span></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas;"><span><span style="color: #c00000;"><span style="font-size: 9.5pt;">$newUser </span></span></span><span><span style="font-size: 9.5pt;"><span style="color: #000000;">= </span><span><span style="color: #c00000;">$computer</span></span><span style="color: #000000;">.Create(</span><span style="mso-themecolor: background2; mso-themeshade: 64; mso-style-textfill-fill-color: #4a452a; mso-style-textfill-fill-themecolor: background2; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-colortransforms: lumm=25000;"><span style="color: #4a452a;">"user"</span></span><span style="color: #000000;">, </span><span><span style="color: #c00000;">$netuser</span></span><span style="color: #000000;">)</span></span></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas;"><span><span style="color: #c00000;"><span style="font-size: 9.5pt;">$newUser</span></span></span><span><span style="font-size: 9.5pt;"><span style="color: #000000;">.put(</span><span style="mso-themecolor: background2; mso-themeshade: 64; mso-style-textfill-fill-color: #4a452a; mso-style-textfill-fill-themecolor: background2; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-colortransforms: lumm=25000;"><span style="color: #4a452a;">"Description"</span></span><span style="color: #000000;">, </span><span style="mso-themecolor: background2; mso-themeshade: 64; mso-style-textfill-fill-color: #4a452a; mso-style-textfill-fill-themecolor: background2; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-colortransforms: lumm=25000;"><span style="color: #4a452a;">"Owner of shared folders in Azure"</span></span><span style="color: #000000;">)</span></span></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas;"><span><span style="color: #c00000;"><span style="font-size: 9.5pt;">$newUser</span></span></span><span><span style="font-size: 9.5pt;"><span style="color: #000000;">.SetPassword(</span><span><span style="color: #c00000;">$password</span></span><span style="color: #000000;">)</span></span></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas;"><span><span style="color: #c00000;"><span style="font-size: 9.5pt;">$newUser</span></span></span><span><span style="color: #000000; font-size: 9.5pt;">.SetInfo()</span></span></span></p>
<p>
<p>All that is left is for the shared folder to be created. You must grant the required permissions to the account previously created for the share to be accessible remotely. The simplest way to share a folder is via the <span style="font-family: courier new,courier;">net share </span>command. When you grant access to an account via <span style="font-family: courier new,courier;">net share </span>you don&rsquo;t automatically give permissions to access the local directory being shared so you will also need to grant the appropriate permissions to the local directory. Here is a PowerShell function that grants full permissions to a local folder to the $netuser account and creates a network share for this account to use:</p>
<p class="MsoNormal"><span><span style="font-family: Consolas;"><span style="color: #000000;"><span style="font-size: 9.5pt;">&nbsp;</span></span></span></span></p>
<p class="MsoNormal"><span><span style="font-family: Consolas;"><span style="color: #000000;"><span style="font-size: 9.5pt;">function </span></span><span style="font-size: 9.5pt;"><b style="mso-bidi-font-weight: normal;"><span style="mso-themecolor: accent4; mso-themeshade: 191; mso-style-textfill-fill-color: #604a7b; mso-style-textfill-fill-themecolor: accent4; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-colortransforms: lumm=75000;"><span style="color: #604a7b;">share_folder</span></span></b><span style="color: #000000;">(</span><span><span style="color: #c00000;">$folder</span></span><span style="color: #000000;">, </span><span><span style="color: #c00000;">$label</span></span><span style="color: #000000;">) {</span></span></span></span></p>
<p class="MsoNormal"><span><span style="font-family: Consolas;"><span style="mso-spacerun: yes;"><span style="color: #000000;"><span style="font-size: 9.5pt;">&nbsp; </span></span></span><span style="font-size: 9.5pt;"><span><span style="color: #c00000;">$acl </span></span><span style="color: #000000;">= </span><span style="mso-themecolor: text2; mso-style-textfill-fill-color: #558ed5; mso-style-textfill-fill-themecolor: text2; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-colortransforms: 'lumm=60000 lumo=40000'; mso-themetint: 153;"><span style="color: #558ed5;">get-acl </span></span></span><span><span style="color: #c00000; font-size: 9.5pt;">$folder</span></span></span></span></p>
<p class="MsoNormal"><span><span style="font-family: Consolas;"><span style="mso-spacerun: yes;"><span style="color: #000000;"><span style="font-size: 9.5pt;">&nbsp; </span></span></span><span style="font-size: 9.5pt;"><span><span style="color: #c00000;">$accessRule </span></span><span style="color: #000000;">= </span><span style="mso-themecolor: text2; mso-style-textfill-fill-color: #558ed5; mso-style-textfill-fill-themecolor: text2; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-colortransforms: 'lumm=60000 lumo=40000'; mso-themetint: 153;"><span style="color: #558ed5;">New-Object</span></span><span style="color: #000000;"> </span><b style="mso-bidi-font-weight: normal;"><span style="mso-themecolor: accent4; mso-themeshade: 191; mso-style-textfill-fill-color: #604a7b; mso-style-textfill-fill-themecolor: accent4; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-colortransforms: lumm=75000;"><span style="color: #604a7b;">System.Security.AccessControl.FileSystemAccessRule</span></span></b><span style="color: #000000;">(</span><span><span style="color: #c00000;">$netuser</span></span><span style="color: #000000;">,"</span><span style="mso-themecolor: background2; mso-themeshade: 64; mso-style-textfill-fill-color: #4a452a; mso-style-textfill-fill-themecolor: background2; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-colortransforms: lumm=25000;"><span style="color: #4a452a;">FullControl</span></span><span style="color: #000000;">","</span><span style="mso-themecolor: background2; mso-themeshade: 64; mso-style-textfill-fill-color: #4a452a; mso-style-textfill-fill-themecolor: background2; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-colortransforms: lumm=25000;"><span style="color: #4a452a;">Allow</span></span><span style="color: #000000;">")</span></span></span></span></p>
<p class="MsoNormal"><span><span style="font-family: Consolas;"><span style="mso-spacerun: yes;"><span style="color: #000000;"><span style="font-size: 9.5pt;">&nbsp; </span></span></span><span style="font-size: 9.5pt;"><span><span style="color: #c00000;">$acl</span></span><span style="color: #000000;">.SetAccessRule(</span><span><span style="color: #c00000;">$accessRule</span></span><span style="color: #000000;">)</span></span></span></span></p>
<p class="MsoNormal"><span><span style="font-family: Consolas;"><span style="mso-spacerun: yes;"><span style="color: #000000;"><span style="font-size: 9.5pt;">&nbsp; </span></span></span><span style="font-size: 9.5pt;"><span style="mso-themecolor: text2; mso-style-textfill-fill-color: #558ed5; mso-style-textfill-fill-themecolor: text2; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-colortransforms: 'lumm=60000 lumo=40000'; mso-themetint: 153;"><span style="color: #558ed5;">set-acl </span></span><span style="color: #000000;">-path </span><span><span style="color: #c00000;">$folder </span></span><span style="color: #000000;">-AclObject </span></span><span><span style="color: #c00000; font-size: 9.5pt;">$acl</span></span></span></span></p>
<p class="MsoNormal"><span><span style="font-family: Consolas;"><span style="color: #000000; font-size: 9.5pt;">&nbsp;</span></span></span></p>
<p class="MsoNormal"><span><span style="font-family: Consolas;"><span style="mso-spacerun: yes;"><span style="color: #000000;"><span style="font-size: 9.5pt;">&nbsp; </span></span></span><span style="font-size: 9.5pt;"><span><span style="color: #c00000;">$full_perm </span></span><span style="color: #000000;">= "</span><span style="mso-themecolor: background2; mso-themeshade: 64; mso-style-textfill-fill-color: #4a452a; mso-style-textfill-fill-themecolor: background2; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-colortransforms: lumm=25000;"><span style="color: #4a452a;">/GRANT:</span></span><span style="color: #000000;">" + </span><span><span style="color: #c00000;">$netuser </span></span><span style="color: #000000;">+ "</span><span style="mso-themecolor: background2; mso-themeshade: 64; mso-style-textfill-fill-color: #4a452a; mso-style-textfill-fill-themecolor: background2; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-colortransforms: lumm=25000;"><span style="color: #4a452a;">,FULL</span></span><span style="color: #000000;">"</span></span></span></span></p>
<p class="MsoNormal"><span><span style="font-family: Consolas;"><span style="color: #000000; font-size: 9.5pt;">&nbsp;</span></span></span></p>
<p class="MsoNormal"><span><span style="font-family: Consolas;"><span style="mso-spacerun: yes;"><span style="color: #000000;"><span style="font-size: 9.5pt;">&nbsp; </span></span></span><span style="font-size: 9.5pt;"><span style="mso-themecolor: text2; mso-style-textfill-fill-color: #558ed5; mso-style-textfill-fill-themecolor: text2; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-colortransforms: 'lumm=60000 lumo=40000'; mso-themetint: 153;"><span style="color: #558ed5;">net share </span></span><span><span style="color: #c00000;">$label</span></span><span style="color: #000000;">`=</span><span><span style="color: #c00000;">$folder</span></span><span style="color: #000000;"> "</span><span><span style="color: #c00000;">$full_perm</span></span><span style="color: #000000;">"</span></span></span></span></p>
<p class="MsoNormal"><span><span style="font-family: Consolas;"><span style="color: #000000; font-size: 9.5pt;">}</span></span></span></p>
<p>
<p>These commands must be executed with elevated privileges hence they must be in a startup task. The sample project at the end of this post has all these scripts bundled in the solution to demonstrate how to create and use shared folders.</p>
<h2>Allocating Space</h2>
<p>You should create all folders intended for sharing in the C: drive&nbsp;where you will find the bulk of&nbsp;the free disk space for a role.</p>
<p>You must also choose a virtual machine size with enough local disk space to support your application. This page lists the VM sizes and the amount of local storage in each one - <a href="http://msdn.microsoft.com/library/ee814754.aspx">http://msdn.microsoft.com/library/ee814754.aspx</a></p>
<h2>Using Shared Folders</h2>
<p>All Azure VMs accessing network drives must have the same network configuration applied, i.e. endpoints defined and firewall rules updated. They must also have the account created with the exact same credentials as the file server(s).</p>
<p>Before a shared folder can be used it must be discovered. Unfortunately it is not possible to use network discovery in Azure. To make matters worse both IP addresses and hostnames are dynamically assigned by Azure at each deployment. Some strategy is needed to make this possible.</p>
<p align="center"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/metablogapi/2870.image_5F699FD9.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-42-40-metablogapi/2870.image_5F00_5F699FD9.png"><img height="165" width="244" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/metablogapi/2783.image_thumb_77AC9427.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-42-40-metablogapi/2783.image_5F00_thumb_5F00_77AC9427.png" alt="image" border="0" title="image" style="background-image: none; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" /></a></p>
<p>Creating two separate roles makes the discovery simple. A &ldquo;File Server Role&rdquo; containing a single instance can be discovered through the Azure runtime API.</p>
<p class="MsoNormal"><span><span style="font-family: Consolas;"><span style="mso-spacerun: yes;"><span style="color: #000000;"><span style="font-size: 9.5pt;"></span></span></span></span></span></p>
<p class="MsoNormal"><span><span style="font-family: Consolas;"><span style="mso-spacerun: yes;"><span style="color: #000000;"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-size: 9.5pt;"><span><span style="color: #0000ff;">var</span></span><span style="color: #000000;"> fileServer = </span><span><span style="color: #2b91af;">RoleEnvironment</span></span><span style="color: #000000;">.Roles[</span><span><span style="color: #a31515;">"FileServerRole"</span></span><span style="color: #000000;">].Instances[0];</span></span></span></span></p>
<p class="MsoNormal"><span><span style="font-family: Consolas;"><span style="mso-spacerun: yes;"><span style="color: #000000;"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-size: 9.5pt;"><span><span style="color: #0000ff;">var</span></span><span style="color: #000000;"> ipaddress = fileServer.InstanceEndpoints[</span><span><span style="color: #a31515;">"SMB"</span></span><span style="color: #000000;">].IPEndpoint.Address;</span></span></span></span></p>
<p>
<p>The discovery logic can be added to the Application Role&rsquo;s OnStart() and made available to the application logic via environment variable or injected in the application configuration before it is launched. Alternatively the file server(s) could write their IP address(es) to an Azure Table or Blob at start up. Each client would look up servers in the well-known storage location at startup. I will use the two-role configuration as an example for the rest of this post, all concepts should apply regardless of deployment topology.</p>
<p>Azure roles are started as services. The best practice for services is not to mount shared drives but Instead use UNC paths. Assuming the drive letter your application uses is configurable you should change it for the UNC path constructed using the IP address discovered through the Azure runtime API. So instead of <span style="font-family: courier new,courier;"><span style="color: #0000ff;">X:\</span></span> your application should be configured with <span style="color: #0000ff;"><span style="font-family: courier new,courier;">\\10.x.x.x\</span></span>.</p>
<p>The last piece of the puzzle is the credentials your application uses to access the network drive. By default it will be using SYSTEM but it needs to authenticate with the file share&nbsp;using the account created at startup time otherwise it will be denied access. The programmatic way to switch identities is impersonation, you can read more about it here <a href="http://msdn.microsoft.com/en-us/library/aa376391(VS.85).aspx">http://msdn.microsoft.com/en-us/library/aa376391(VS.85).aspx</a>. Using impersonation from C# is easy but it takes multiple steps. Instead of showing the entire code here you can download the sample solution below to see how it works.</p>
<h2>Sample Project</h2>
<p>This solution puts it all together, it demonstrates the file sharing and access to the network drive. It is available here: <a href="http://cid-76556b7fc951f312.office.live.com/self.aspx/Public/SharedFolder.zip">http://cid-76556b7fc951f312.office.live.com/self.aspx/Public/SharedFolder.zip</a></p>
<p>The File Share Role is a Web Role so you can have some visual feedback for how it works. Navigating to the default page for the project will present you with a list of all clients' names and IP addresses. What's interesting is how this list is created - each instance in the Application Role writes a single file to the shared drive in the format <em>hostname</em>-<em>IP address</em>. The page simply lists of&nbsp;all files in the shared folder. </p>
<p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/3005.client.jpg" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-42-40/3005.client.jpg" border="0" /></p>
<p>The point of this solution is to demonstrate sharing and accessing network drives. If you create additional tests post your results in the comments. I am sure I/O results will be popular.</p>
<p>I used ExtraSmall VMs in the solution. If you didn't sign up for the beta you will have to change the VM size to at least Small.</p>
<h2>Final Thoughts</h2>
<p>It does takes&nbsp;some effort&nbsp;to make Shared Folders work in Azure. Most if not all of it is boilerplate code that can be added to any Role as startup logic.</p>
<p>The main drawback of this approach is the single point of failure in the File Server Role. Worse yet, if something happens to that single instance or Azure needs to move it to another physical host all data will be lost. One way to solve this problem is to use Azure Drive and share a folder from it. This way all data will be persisted in Azure Storage and in case of a server failure or relocation no data will be lost.</p>
</p>
</p>
</p>
</p>
</p>]]></content:encoded>
    </item>
    <item>
      <title>Deploying Java Applications in Azure</title>
      <link>https://docs.microsoft.com/archive/blogs/mariok/deploying-java-applications-in-azure</link>
      <pubDate>Wed, 05 Jan 2011 16:15:00 GMT</pubDate>
      <dc:creator><![CDATA[Mario Kosmiskas]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mariok/2011/01/05/deploying-java-applications-in-azure/</guid>
      <description><![CDATA[You have an existing Java application or are developing a new one and want to take advantage of the...]]></description>
      <content:encoded><![CDATA[<p>You have an existing Java application or are developing a new one and want to take advantage of the cloud? Azure is an attractive platform for deploying a variety of applications, including Java based apps.</p>
<p>In Azure you simply upload your application and the plumbing is all put in place for you. No need to manage Operating System installs or patches. Understanding how to package a Java application for deployment in Azure and the options you have in that process is what I will discuss here.</p>
<p>I am assuming you have a basic understanding of Azure so I won&rsquo;t introduce any concepts here. If that is not the case you might want to visit <a href="http://www.microsoft.com/windowsazure/">http://www.microsoft.com/windowsazure/</a> to get an overview of Azure prior to reading this page.</p>
<h4>How to run a Java Application in Azure</h4>
<p>Azure requires a &lsquo;Role&rsquo; to run your application. The Worker Role is the best type of Role to host a Java application. Instances of a Worker Role can be seen as fresh installs of Windows Server ready to run an application.</p>
<p>The Worker Role configuration is included in the deployment package you upload to Azure along with your application. The Role provides hooks to launch a Java application and ways to communicate with the Azure runtime.</p>
<p>Creating a Role involves adding it to the service definition file, setting attributes in the service configuration file and providing a class to handle the Role lifecycle. Let&rsquo;s look into the main options in each of these files as it relates to deploying Java applications. I am using the Azure SDK 1.3 and will be talking about features introduced in that release. </p>
<h5>Service Definition</h5>
<p>The service definition file lists all Roles in your Azure service. I will cover Port Reservation and Startup Tasks.</p>
<h6><em>Port Reservation</em></h6>
<p>Of critical importance to Java applications running in the cloud is the specification of the required TCP ports the application uses. Azure will block communications to any port you don&rsquo;t explicitly list in your service definition. You will need to add a <span style="color: #c0504d;">InputEndpoint</span> entry for every public port your application uses to receive requests. These ports will be configured both as a Windows Firewall rule and programmed in the Load Balancer. Remember you can have any number of instances of the same Role and they will all be configured behind a load balancer. </p>
<p>This is an example of how you would configure a Role that hosts a Java application which uses port 80 to accept HTTP requests:</p>
<p><span style="font-family: Consolas;"><span style="line-height: 11pt;"><span style="color: #0000ff;"><span>&lt;</span></span></span><span><span style="line-height: 11pt;"><span style="color: #a31515;">InputEndpoint</span></span><span style="line-height: 11pt;"><span style="color: #0000ff;"> </span></span><span style="line-height: 11pt;"><span style="color: #ff0000;">name</span></span><span style="line-height: 11pt;"><span style="color: #0000ff;">=</span></span></span><span style="line-height: 11pt;"><span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">Http</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">protocol</span></span><span><span style="color: #0000ff;">=</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">tcp</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">port</span></span><span><span style="color: #0000ff;">=</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">80</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">localPort</span></span><span><span style="color: #0000ff;">=</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">8080</span></span><span style="color: #000000;">"</span></span><span><span style="color: #0000ff;"> /&gt;</span></span></span></span></p>
<p>Notice the protocol is set to "<span style="color: #0000ff;">tcp</span>" even though the application is actually using HTTP. "<span style="color: #0000ff;">http</span>" is a valid value for the protocol attribute but you must never use it for Java applications. The "<span style="color: #0000ff;">http</span>" value has a specific meaning in Azure and is reserved for .NET applications.</p>
<p>The <span style="color: #ff0000;">port</span> attribute specifies the public port that will be available for client requests. The <span style="color: #ff0000;">localPort</span> tells Azure the port your application is actually listening on. Azure will map the public port on the load balancer to the local port your application is using. Those values don&rsquo;t need to be different, in fact most applications will likely use the same local and external port.</p>
<p>It is also important to know that <span style="color: #ff0000;">localPort</span> is an optional attribute. If you don&rsquo;t define it Azure will dynamically open a port for your application. Since all requests will be mapped to that port your application must inquire the Azure runtime for the assigned port number to receive requests. Although optional you should probably always set the <span style="color: #ff0000;">localPort</span>.</p>
<p>The local port reservation has some limitations when it comes to the Compute Emulator (or Development Fabric). Because the Compute Emulator is running on your desktop it may not be able to bind to the port you requested because another application might have reserved the port. That is always the case for port 80 because IIS is already using it. If you intend on using the Compute Emulator you will need to get the dynamically assigned port at runtime, at least in development.</p>
<h6><em>Startup Tasks</em></h6>
<p>Startup Tasks are commands launched before your Role is initialized. They were created to allow a Role to perform any configuration before requests are forwarded to the Role instance.</p>
<p>A unique feature of Startup Tasks is the ability to run with elevated (administrator) privileges. This is usually required if your application needs to launch an installer. All installers must also run in silent or unattended mode. In fact the Oracle JVM installer does require administrator privileges to run and does support silent mode. If you plan on installing it you will have to use a Startup Task. </p>
<p>Another characteristic of Startup Tasks is the ability to write to any folder. Regular Azure applications must define working directories and can only write to them. That limitation does not apply to Startup Tasks. That facilitates the job of some installers and can also be beneficial to some Java application servers.</p>
<p>By now you must be thinking that you can just launch your Java application as a Startup Task and be done. In fact that is one option for launching Java applications but as usual is has some drawbacks. I will talk about this option shortly.</p>
<h5>Service Configuration</h5>
<p>Configurations are companions to Service Definitions. For every Role you define you must have a configuration entry.</p>
<p>Here is where you specify how many instances of your Role you would like to have. You will also define various settings for your Role.</p>
<p>One such setting of interest is the version of Windows Server. You can choose between Windows Server 2008 and Windows Server 2008 R2. For the most part the underlying operating system is irrelevant to a Java application. That continues to be true in Azure. If your application doesn&rsquo;t rely directly on a specific Windows feature nor it depends on a 3<sup>rd</sup> party tool that does you can ignore this setting.</p>
<p>There are important differences between these Windows Server families though. The one I am interested in is Power Shell. Windows Server 2008 R2 includes Power Shell 2.0 which &ndash; as I&rsquo;ll soon demonstrate &ndash; can be used to greatly simply the deployment of Java applications.</p>
<h5>Azure Role Entry Point</h5>
<p>The Role Entry Point is the interface between your application and the Azure runtime. Azure will instantiate and call your Role Entry Point providing you with the opportunity to take actions at different stages of the Role lifecycle.</p>
<p>This is where you will be doing some .NET programming. At this point Azure requires the Role Entry Point to be written in either C# or VB.NET. The amount of code in your Role Entry Point will vary based on the complexity of your application. It can be as simple as a few lines of code.</p>
<p>Three methods define the role lifecycle: OnStart, OnStop and Run. OnStart is called before your application receives live traffic. You should do any initialization in this step. To a certain extent this is akin to a synchronous Startup Task. OnStop is called when Azure is shutting down your role to allow for a graceful shutdown. Run is called when Azure is ready to forward live traffic to your application. The call to Run must not return while your Role is operational. If it returns Azure will interpret it as a failure of your application and will recycle your Role instance. This behavior can be of interest to certain applications and should be used to request Azure to recycle your Role instance in case of a failure. You can envision a heartbeat check on the JVM being executed from Run and returning in case of either application or JVM failure, causing Azure to restart your Role and bring your application back to a running state. </p>
<h4>Java Virtual Machine, Libraries and Resources</h4>
<p>Now that you understand how to configure a Role to run your Java application you need to provide it with a JVM. The best way to do it is to upload the JVM to Azure Blob Storage and install it during Role initialization, either as a Startup Task or in the Role Entry Point&rsquo;s OnStart.</p>
<p>Most Java runtimes can be simply copied to a new machine, no install is necessary. If your JVM can be installed this way you should create a ZIP archive and upload it to Azure Blob Storage. Because you may need to maintain multiple versions of the JVM I recommend creating a separate container to hold all the JVMs you need. Inside that container you can keep JDKs and/or JREs named after the corresponding Java version.</p>
<p>If you need to run an installer which requires administrator privileges you have to use a Startup Task. If you can copy the JVM you have a choice.</p>
<p>Depending on your build process you might want to use the same strategy for other dependencies. Libraries like Spring, Log4J, Apache Commons can also be in the cloud and pulled from Azure Blob Storage before your application starts. Imagine doing the same for the application server or web server your application uses. I personally like to create a separate container called &lsquo;apps&rsquo; for Jetty, Tomcat and other servers.</p>
<h4>Launching the Java application</h4>
<p>With everything in place the only step left is to launch the Java application. It can also be done from either the Role Entry Point or from a Startup Task.</p>
<p>Believe it or not there is enough to discuss in each of these alternatives that will save them for future posts.</p>
<p>As a cliffhanger I will tell you the high level differences between the two options. Using the Role Entry Point to launch your Java application will give you full control over the lifecycle of the role and allows for your application to react to environment changes (e.g. discover when instances are added or removed). It does require you to write.NET code. Using Startup Tasks requires potentially no .NET knowledge plus gives you the ability to run with elevated privileges at the cost of having little to no access to the role lifecycle.</p>
<p>The path you take will vary based on your application.</p>
<h4>Packaging and Deploying the Java application</h4>
<p>The Azure SDK includes tools to package an application along with the Service Definition and Configuration. The Windows Azure Packaging Tool (cspack.exe) is the main tool to use for this job. Visual Studio provides a convenient frontend for cspack and is also capable of initiating a deployment.</p>
<p>Cspack.exe is more desirable for integrating with exiting Java builds. It is only available on Windows so you will have to do the packaging of the Azure deployment on a Windows box. I will also save the explanation on using cpspack for a future post.</p>
<h4>Putting it all together: Jetty 7 in Azure</h4>
<p>I did not want to finish without showing how all of this can work. I will demonstrate how to get Jetty 7 working with the minimum amount of effort. Running a full web application on Jetty will require extra steps like deploying your own WAR/EAR but for demonstration purposes I will deploy Jetty as is and access the ROOT web app.</p>
<p>I picked Jetty because I wanted to show an application that uses NIO working in Azure. You should be able to deploy any other web server the same way. David Chou has previously posted <a href="http://blogs.msdn.com/b/dachou/archive/2010/03/21/run-java-with-jetty-in-windows-azure.aspx">a great article on running Jetty in Azure</a>. He wrote it for the SDK 1.2 but a lot of the information there still applies.</p>
<p>You will need a Java 6 compatible JVM, the latest Jetty 7 distribution in zip format, the Azure SDK 1.3 (or later) and Visual Studio 2010. The free edition of Visual Studio 2010 will do. You will also need a .NET library to handle ZIP files. I used <a href="http://www.icsharpcode.net/OpenSource/SharpZipLib/">http://www.icsharpcode.net/OpenSource/SharpZipLib/</a> but other popular libraries exist and can be used with little change to the deployment scripts.</p>
<p>Start by installing Visual Studio and the Azure SDK. If you are using Oracle&rsquo;s JVM you will need to install it locally then create a zip file of the JRE. If you installed the JDK in the default location you can navigate to C:\Program Files\Java\jdk1.6.0_&lt;update #&gt;, right click on the JRE directory and create a zip folder. The deployment script expects this file to be named jre1.6.0_22.zip.</p>
<p>Upload both the JRE.zip and Jetty to your Azure Storage account. Put the jre.zip in a container called &lsquo;java&rsquo; and the jetty-distribution-7.x.x.&lt;date&gt;.zip in a container called &lsquo;apps&rsquo;. You can change these container and file names but you will need to update the Launch.ps1 script.</p>
<p>You can download this Visual Studio 2010 project (almost) ready to be deployed. You will need to enter your storage account credentials to get it to work.</p>
<p><iframe scrolling="no" marginwidth="0" frameborder="0" src="http://cid-76556b7fc951f312.office.live.com/embedicon.aspx/Public/MinimalJavaWorkerRole.zip" marginheight="0" title="Preview" style="background-color: #fcfcfc; width: 98px; height: 115px; padding: 0px;"></iframe></p>
<p>If you decide to create the project from scratch you should add the SharpZipLib DLL to a &lsquo;lib&rsquo; folder in your project.</p>
<h5>Minimal role code</h5>
<p>This example will launch Jetty from a Startup Task. The only requirement for the Role Entry Point is to not return from Run so this code blocks indefinitely. </p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span>&nbsp;</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span>using</span></span></span><span><span style="color: #000000;"> System.Threading;</span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span>using</span></span></span><span><span style="color: #000000;"> Microsoft.WindowsAzure.ServiceRuntime;</span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="color: #000000;">&nbsp;</span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span>namespace</span></span></span><span><span style="color: #000000;"> JettyWorkerRole</span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="color: #000000;">{</span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="mso-spacerun: yes;"><span style="color: #000000;"><span>&nbsp;&nbsp;&nbsp; </span></span></span><span><span><span style="color: #0000ff;">public</span></span><span style="color: #000000;"> </span><span><span style="color: #0000ff;">class</span></span><span style="color: #000000;"> </span><span><span style="color: #2b91af;">WorkerRole</span></span><span style="color: #000000;"> : </span></span><span><span style="color: #2b91af;">RoleEntryPoint</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="color: #000000;"><span style="mso-spacerun: yes;"><span>&nbsp;&nbsp;&nbsp; </span></span><span>{</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="mso-spacerun: yes;"><span style="color: #000000;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span><span><span style="color: #0000ff;">public</span></span><span style="color: #000000;"> </span><span><span style="color: #0000ff;">override</span></span><span style="color: #000000;"> </span><span><span style="color: #0000ff;">void</span></span><span style="color: #000000;"> Run()</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="color: #000000;"><span style="mso-spacerun: yes;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span>{</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="mso-spacerun: yes;"><span style="color: #000000;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span><span><span style="color: #0000ff;">while</span></span><span style="color: #000000;"> (</span><span><span style="color: #0000ff;">true</span></span><span style="color: #000000;">)</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="mso-spacerun: yes;"><span style="color: #000000;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span><span><span style="color: #2b91af;">Thread</span></span><span style="color: #000000;">.Sleep(10000);</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="color: #000000;"><span style="mso-spacerun: yes;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span>}</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="color: #000000;"><span style="mso-spacerun: yes;"><span>&nbsp;&nbsp;&nbsp; </span></span><span>}</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="color: #000000;">}</span></span></span></p>
<h5>Service definition</h5>
<p>There is a single Startup Task to execute &lsquo;Run.cmd&rsquo; with regular user (limited) privileges. The task type &lsquo;background&rsquo; decouples the execution of the task from the Role lifecycle.</p>
<p>I also specify the public port 80 to accept request but internally Jetty will use port 8080.</p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span>&nbsp;</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span>&lt;?</span></span></span><span><span><span style="color: #a31515;">xml</span></span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">version</span></span><span><span style="color: #0000ff;">=</span></span></span><span><span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">1.0</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">encoding</span></span><span><span style="color: #0000ff;">=</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">utf-8</span></span><span style="color: #000000;">"</span></span><span><span style="color: #0000ff;">?&gt;</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span>&lt;</span></span></span><span><span><span style="color: #a31515;">ServiceDefinition</span></span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">name</span></span><span><span style="color: #0000ff;">=</span></span></span><span><span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">MinimalJavaWorkerRole</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">xmlns</span></span><span><span style="color: #0000ff;">=</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition</span></span><span style="color: #000000;">"</span></span><span><span style="color: #0000ff;">&gt;</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span style="mso-spacerun: yes;"><span>&nbsp; </span></span><span>&lt;</span></span></span><span><span><span style="color: #a31515;">WorkerRole</span></span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">name</span></span><span><span style="color: #0000ff;">=</span></span></span><span><span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">JettyWorkerRole</span></span><span style="color: #000000;">"</span></span><span><span style="color: #0000ff;">&gt;</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span style="mso-spacerun: yes;"><span>&nbsp;&nbsp;&nbsp; </span></span><span>&lt;</span></span></span><span><span><span style="color: #a31515;">Startup</span></span></span><span><span style="color: #0000ff;">&gt;</span></span></span><span>&nbsp;</span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span style="mso-spacerun: yes;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span>&lt;</span></span></span><span><span><span style="color: #a31515;">Task</span></span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">commandLine</span></span><span><span style="color: #0000ff;">=</span></span></span><span><span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">Run.cmd</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">executionContext</span></span><span><span style="color: #0000ff;">=</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">limited</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">taskType</span></span><span><span style="color: #0000ff;">=</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">background</span></span><span style="color: #000000;">"</span></span><span><span style="color: #0000ff;"> /&gt;</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span style="mso-spacerun: yes;"><span>&nbsp;&nbsp;&nbsp; </span></span><span>&lt;/</span></span></span><span><span><span style="color: #a31515;">Startup</span></span></span><span><span style="color: #0000ff;">&gt;</span></span></span><span>&nbsp;</span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span style="mso-spacerun: yes;"><span>&nbsp;&nbsp;&nbsp; </span></span><span>&lt;</span></span></span><span><span><span style="color: #a31515;">Endpoints</span></span></span><span><span style="color: #0000ff;">&gt;</span></span></span><span>&nbsp;</span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span style="mso-spacerun: yes;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span>&lt;</span></span></span><span><span><span style="color: #a31515;">InputEndpoint</span></span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">name</span></span><span><span style="color: #0000ff;">=</span></span></span><span><span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">Http</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">protocol</span></span><span><span style="color: #0000ff;">=</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">tcp</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">port</span></span><span><span style="color: #0000ff;">=</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">80</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">localPort</span></span><span><span style="color: #0000ff;">=</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">8080</span></span><span style="color: #000000;">"</span></span><span><span style="color: #0000ff;"> /&gt;</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span style="mso-spacerun: yes;"><span>&nbsp;&nbsp;&nbsp; </span></span><span>&lt;/</span></span></span><span><span><span style="color: #a31515;">Endpoints</span></span></span><span><span style="color: #0000ff;">&gt;</span></span></span><span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span style="mso-spacerun: yes;"><span>&nbsp; </span></span><span>&lt;/</span></span></span><span><span><span style="color: #a31515;">WorkerRole</span></span></span><span><span style="color: #0000ff;">&gt;</span></span></span><span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span>&lt;/</span></span></span><span><span><span style="color: #a31515;">ServiceDefinition</span></span></span><span><span style="color: #0000ff;">&gt;</span></span></span></p>
<h5>Service configuration</h5>
<p>The default service configuration sets the number of instances for the role to 1. Feel free to increase it if you&rsquo;d like, this example will work with any number of instances.</p>
<p>A little hidden in this configuration is the <span style="color: #ff0000;">osFamily</span>. This is where you specify the family of Windows Server you would like to use. It must be set to Windows Server 2008 R2 which is indicated by the family 2. This is needed because I use PowerShell 2.0 in this example.</p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span></span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span>&lt;?</span></span></span><span><span><span style="color: #a31515;">xml</span></span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">version</span></span><span><span style="color: #0000ff;">=</span></span></span><span><span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">1.0</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">encoding</span></span><span><span style="color: #0000ff;">=</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">utf-8</span></span><span style="color: #000000;">"</span></span><span><span style="color: #0000ff;">?&gt;</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span>&lt;</span></span></span><span><span><span style="color: #a31515;">ServiceConfiguration</span></span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">serviceName</span></span><span><span style="color: #0000ff;">=</span></span></span><span><span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">MinimalJavaWorkerRole</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">xmlns</span></span><span><span style="color: #0000ff;">=</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">osFamily</span></span><span><span style="color: #0000ff;">=</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">2</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">osVersion</span></span><span><span style="color: #0000ff;">=</span></span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">*</span></span><span style="color: #000000;">"</span></span><span><span style="color: #0000ff;">&gt;</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span style="mso-spacerun: yes;"><span>&nbsp; </span></span><span>&lt;</span></span></span><span><span><span style="color: #a31515;">Role</span></span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">name</span></span><span><span style="color: #0000ff;">=</span></span></span><span><span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">JettyWorkerRole</span></span><span style="color: #000000;">"</span></span><span><span style="color: #0000ff;">&gt;</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span style="mso-spacerun: yes;"><span>&nbsp;&nbsp;&nbsp; </span></span><span>&lt;</span></span></span><span><span><span style="color: #a31515;">Instances</span></span><span><span style="color: #0000ff;"> </span></span><span><span style="color: #ff0000;">count</span></span><span><span style="color: #0000ff;">=</span></span></span><span><span><span style="color: #000000;">"</span><span><span style="color: #0000ff;">1</span></span><span style="color: #000000;">"</span></span><span><span style="color: #0000ff;"> /&gt;</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span style="mso-spacerun: yes;"><span>&nbsp; </span></span><span>&lt;/</span></span></span><span><span><span style="color: #a31515;">Role</span></span></span><span><span style="color: #0000ff;">&gt;</span></span></span><span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span><span style="color: #0000ff;"><span>&lt;/</span></span></span><span><span><span style="color: #a31515;">ServiceConfiguration</span></span></span><span><span style="color: #0000ff;">&gt;</span></span></span></p>
<h5>Run.cmd</h5>
<p>This is a command used to launch the PowerShell script which contains the actual deployment logic. This file is not strictly needed but Visual Studio makes checks for the existence of the <span style="color: #ff0000;">commandLine</span>. So if you use Visual Studio you must have it.</p>
<p>I&rsquo;m relaxing the security on the PowerShell script execution. In production you should sign the PowerShell script instead.</p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="color: #000000;"></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="color: #000000;">powershell -executionpolicy unrestricted -file .\Launch.ps1</span></span></span></p>
<p>A word of caution if you are new to Visual Studio &ndash; text files are saved in UTF-8 by default. It should be otherwise fine with this content if it wasn&rsquo;t for the byte order mark. Because of that you must make sure to change the encoding for this file. You can do this in the &ldquo;Save As..&rdquo; option, here are the steps.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/metablogapi/8054.image_5025E5A7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-42-40-metablogapi/8054.image_5F00_5025E5A7.png"><img height="169" width="244" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/metablogapi/7206.image_thumb_5CB392C3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-42-40-metablogapi/7206.image_5F00_thumb_5F00_5CB392C3.png" alt="image" border="0" title="image" style="background-image: none; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" /></a>&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/metablogapi/3582.image_5594564B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-42-40-metablogapi/3582.image_5F00_5594564B.png"><img height="91" width="220" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/metablogapi/4152.image_thumb_7C626C8B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-42-40-metablogapi/4152.image_5F00_thumb_5F00_7C626C8B.png" alt="image" border="0" title="image" style="background-image: none; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" /></a>&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/metablogapi/3175.image_4755DD5B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-42-40-metablogapi/3175.image_5F00_4755DD5B.png"><img height="126" width="244" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/metablogapi/3107.image_thumb_4036A0E3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-42-40-metablogapi/3107.image_5F00_thumb_5F00_4036A0E3.png" alt="image" border="0" title="image" style="background-image: none; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" /></a></p>
<h5>Launch.ps1</h5>
<p>This is an overly simplified version of a deployment script. I will expand on it and explain the details of how it works on the post on using Startup Tasks. Basically this script downloads both JRE and Jetty from your storage account, unzips both and launches Jetty.</p>
<p>You must change the <span style="color: #ff0000;">$connection_string</span> to use your Storage Account credentials. You might also need to change <span style="color: #ff0000;">$jre</span> and <span style="color: #ff0000;">$jetty</span> to match the versions you used.</p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="color: #000000;"><span></span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="color: #000000;"><span>function </span></span><span><span style="color: #8064a2;"><b style="mso-bidi-font-weight: normal;"><span style="mso-themecolor: accent4;">unzip</span></b><span style="mso-themecolor: accent4;"> </span></span><span style="color: #000000;">(</span><span><span style="color: #c00000;">$zip</span></span><span style="color: #000000;">, </span><span><span style="color: #c00000;">$destination</span></span><span style="color: #000000;">) {</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="mso-tab-count: 1;"><span style="color: #000000;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span><span style="mso-themecolor: accent1;"><span style="color: #4f81bd;">Add-Type </span></span><span style="color: #000000;">-Path ((</span><span style="mso-themecolor: accent1;"><span style="color: #4f81bd;">Get-Location</span></span><span style="color: #000000;">).Path </span><span style="mso-themecolor: background1; mso-themeshade: 128;"><span style="color: #808080;">+</span></span><span style="color: #000000;"> </span><span style="mso-themecolor: accent2; mso-themeshade: 128;"><span style="color: #632423;">'\lib\ICSharpCode.SharpZipLib.dll'</span></span><span style="color: #000000;">)</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="mso-tab-count: 1;"><span style="color: #000000;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span><span><span style="color: #c00000;">$fs </span></span><span style="color: #000000;">= </span><span style="mso-themecolor: accent1;"><span style="color: #4f81bd;">New-Object </span></span></span><b style="mso-bidi-font-weight: normal;"><span style="mso-themecolor: accent4;"><span style="color: #8064a2;">ICSharpCode.SharpZipLib.Zip.FastZip</span></span></b></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="mso-tab-count: 1;"><span style="color: #000000;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span><span><span style="color: #c00000;">$fs</span></span><span style="color: #000000;">.ExtractZip(</span><span><span style="color: #c00000;">$zip</span></span><span style="color: #000000;">, </span><span><span style="color: #c00000;">$destination</span></span><span style="color: #000000;">, '')</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="color: #000000;">}</span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="color: #000000;">&nbsp;</span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="color: #000000;"><span>function </span></span><span><span style="color: #8064a2;"><b style="mso-bidi-font-weight: normal;"><span style="mso-themecolor: accent4;">download_from_storage</span></b><span style="mso-themecolor: accent4;"> </span></span><span style="color: #000000;">(</span><span><span style="color: #c00000;">$container</span></span><span style="color: #000000;">, </span><span><span style="color: #c00000;">$blob</span></span><span style="color: #000000;">, </span><span><span style="color: #c00000;">$connection</span></span><span style="color: #000000;">, </span><span><span style="color: #c00000;">$destination</span></span><span style="color: #000000;">) {</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="mso-spacerun: yes;"><span style="color: #000000;"><span>&nbsp;&nbsp;&nbsp; </span></span></span><span><span style="mso-themecolor: accent1;"><span style="color: #4f81bd;">Add-Type </span></span><span style="color: #000000;">-Path ((</span><span style="mso-themecolor: accent1;"><span style="color: #4f81bd;">Get-Location</span></span><span style="color: #000000;">).Path + </span><span style="mso-themecolor: accent2; mso-themeshade: 128;"><span style="color: #632423;">'\Microsoft.WindowsAzure.StorageClient.dll'</span></span><span style="color: #000000;">)</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="mso-spacerun: yes;"><span style="color: #000000;"><span>&nbsp;&nbsp;&nbsp; </span></span></span><span><span><span style="color: #c00000;">$storageAccount </span></span><span style="color: #000000;">= </span><span style="mso-themecolor: accent3; mso-themeshade: 191;"><span style="color: #76923c;">[Microsoft.WindowsAzure.CloudStorageAccount]</span></span><span style="mso-themecolor: background1; mso-themeshade: 128;"><span style="color: #808080;">::</span></span><span style="color: #000000;">Parse(</span><span><span style="color: #c00000;">$connection</span></span><span style="color: #000000;">)</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="mso-spacerun: yes;"><span style="color: #000000;"><span>&nbsp;&nbsp;&nbsp; </span></span></span><span><span><span style="color: #c00000;">$blobClient </span></span><span style="color: #000000;">= </span><span style="mso-themecolor: accent1;"><span style="color: #4f81bd;">New-Object </span></span><b style="mso-bidi-font-weight: normal;"><span style="mso-themecolor: accent4;"><span style="color: #8064a2;">Microsoft.WindowsAzure.StorageClient.CloudBlobClient</span></span></b><span style="color: #000000;">(</span><span><span style="color: #c00000;">$storageAccount</span></span><span style="color: #000000;">.BlobEndpoint, </span><span><span style="color: #c00000;">$storageAccount</span></span><span style="color: #000000;">.Credentials)</span></span><span style="mso-spacerun: yes;"><span style="color: #000000;">&nbsp;&nbsp; </span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="mso-spacerun: yes;"><span style="color: #000000;"><span>&nbsp;&nbsp;&nbsp; </span></span></span><span><span><span style="color: #c00000;">$remoteBlob </span></span><span style="color: #000000;">= </span><span><span style="color: #c00000;">$blobClient</span></span><span style="color: #000000;">.GetBlobReference(</span><span><span style="color: #c00000;">$container </span></span><span style="mso-themecolor: background1; mso-themeshade: 128;"><span style="color: #808080;">+</span></span><span style="color: #000000;"> '/' </span><span style="mso-themecolor: background1; mso-themeshade: 128;"><span style="color: #808080;">+</span></span><span style="color: #000000;"> </span><span><span style="color: #c00000;">$blob</span></span><span style="color: #000000;">)</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="mso-spacerun: yes;"><span style="color: #000000;"><span>&nbsp;&nbsp;&nbsp; </span></span></span><span><span><span style="color: #c00000;">$remoteBlob</span></span><span style="color: #000000;">.DownloadToFile(</span><span><span style="color: #c00000;">$destination </span></span><span style="mso-themecolor: background1; mso-themeshade: 128;"><span style="color: #808080;">+</span></span><span style="color: #000000;"> "\" </span><span style="mso-themecolor: background1; mso-themeshade: 128;"><span style="color: #808080;">+</span></span><span style="color: #000000;"> </span><span><span style="color: #c00000;">$blob</span></span><span style="color: #000000;">)</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="color: #000000;">}</span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="color: #000000;">&nbsp;</span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span><span style="color: #c00000;"><span>$connection_string </span></span></span><span><span><span style="color: #000000;">= </span></span><span style="mso-themecolor: accent2; mso-themeshade: 128;"><span style="color: #632423;">'DefaultEndpointsProtocol=http;AccountName=&lt;YOUR_ACCOUNT&gt;;AccountKey=&lt;YOUR_KEY&gt;'</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="color: #000000;">&nbsp;</span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-themecolor: accent3; mso-themeshade: 128;"><span style="font-family: Consolas;"><span style="color: #4f6228;"># JRE</span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span><span style="color: #c00000;"><span>$jre </span></span></span><span><span><span style="color: #000000;">= </span></span><span style="mso-themecolor: accent2; mso-themeshade: 128;"><span style="color: #632423;">'jre1.6.0_22.zip'</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span style="mso-themecolor: accent1;"><span style="color: #4f81bd;"><span>download_from_storage </span></span></span><span><span style="mso-themecolor: accent2; mso-themeshade: 128;"><span style="color: #632423;">'java'</span></span></span><span><span><span style="color: #000000;"> </span><span><span style="color: #c00000;">$jre $connection_string </span></span><span style="color: #000000;">(</span><span style="mso-themecolor: accent1;"><span style="color: #4f81bd;">Get-Location</span></span><span style="color: #000000;">).Path</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span style="mso-themecolor: accent1;"><span style="color: #4f81bd;"><span>unzip </span></span></span><span><span><span style="color: #000000;">((</span><span style="mso-themecolor: accent1;"><span style="color: #4f81bd;">Get-Location</span></span><span style="color: #000000;">).Path </span><span style="mso-themecolor: background1; mso-themeshade: 128;"><span style="color: #808080;">+</span></span><span style="color: #000000;"> </span><span style="mso-themecolor: accent2; mso-themeshade: 128;"><span style="color: #632423;">"\"</span></span><span style="color: #000000;"> </span><span style="mso-themecolor: background1; mso-themeshade: 128;"><span style="color: #808080;">+</span></span><span style="color: #000000;"> </span><span><span style="color: #c00000;">$jre</span></span><span style="color: #000000;">) (</span><span style="mso-themecolor: accent1;"><span style="color: #4f81bd;">Get-Location</span></span><span style="color: #000000;">).Path</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="color: #000000;">&nbsp;</span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-themecolor: accent3; mso-themeshade: 128;"><span style="font-family: Consolas;"><span style="color: #4f6228;"># Jetty</span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span><span style="color: #c00000;"><span>$jetty </span></span></span><span><span><span style="color: #000000;">= </span></span><span style="mso-themecolor: accent2; mso-themeshade: 128;"><span style="color: #632423;">'jetty-distribution-7.2.2.v20101205.zip'</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span style="mso-themecolor: accent1;"><span style="color: #4f81bd;"><span>download_from_storage </span></span></span><span><span style="mso-themecolor: accent2; mso-themeshade: 128;"><span style="color: #632423;">'apps'</span></span></span><span><span><span style="color: #000000;"> </span><span><span style="color: #c00000;">$jetty $connection_string </span></span><span style="color: #000000;">(</span><span style="mso-themecolor: accent1;"><span style="color: #4f81bd;">Get-Location</span></span><span style="color: #000000;">).Path</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span style="mso-themecolor: accent1;"><span style="color: #4f81bd;"><span>unzip </span></span></span><span><span><span style="color: #000000;">((</span><span style="mso-themecolor: accent1;"><span style="color: #4f81bd;">Get-Location</span></span><span style="color: #000000;">).Path </span><span style="mso-themecolor: background1; mso-themeshade: 128;"><span style="color: #808080;">+</span></span><span style="color: #000000;"> </span><span style="mso-themecolor: accent2; mso-themeshade: 128;"><span style="color: #632423;">"\"</span></span><span style="color: #000000;"> </span><span style="mso-themecolor: background1; mso-themeshade: 128;"><span style="color: #808080;">+</span></span><span style="color: #000000;"> </span><span><span style="color: #c00000;">$jetty</span></span><span style="color: #000000;">) (</span><span style="mso-themecolor: accent1;"><span style="color: #4f81bd;">Get-Location</span></span><span style="color: #000000;">).Path</span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span><span style="font-family: Consolas;"><span style="color: #000000;">&nbsp;</span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-themecolor: accent3; mso-themeshade: 128;"><span style="font-family: Consolas;"><span style="color: #4f6228;"># Launch Jetty</span></span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span style="mso-themecolor: accent1;"><span style="color: #4f81bd;"><span>cd </span></span></span><b style="mso-bidi-font-weight: normal;"><span style="mso-themecolor: accent4;"><span style="color: #8064a2;">jetty-distribution-7.2.2.v20101205</span></span></b></span><span></span></p>
<p class="MsoNormal" style="line-height: normal; list-style-type: disc; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Consolas;"><span style="mso-themecolor: accent1;"><span style="color: #4f81bd;"><span>..\jre\bin\java </span></span></span><b style="mso-bidi-font-weight: normal;"><span style="mso-themecolor: accent4;"><span style="color: #8064a2;">`-jar start.jar</span></span></b></span><span></span></p>
<p>You must also tell Visual Studio do include this script in your build. Right-click on Launch.ps1 and select Properties. Make sure the &lsquo;Copy to Output Directory&rsquo; option is set to &lsquo;Copy Always&rsquo;. You will need to do the same thing for Run.cmd and the Zip library.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/metablogapi/5734.image_7BF63996.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-42-40-metablogapi/5734.image_5F00_7BF63996.png"><img height="154" width="244" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/metablogapi/0028.image_thumb_5FE57AAB.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-42-40-metablogapi/0028.image_5F00_thumb_5F00_5FE57AAB.png" alt="image" border="0" title="image" style="background-image: none; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" /></a></p>
<p>Now you are ready to deploy. You can deploy the app directly from Visual Studio, information on how to set it up on this page <a href="http://msdn.microsoft.com/en-us/library/ee460772.aspx">http://msdn.microsoft.com/en-us/library/ee460772.aspx</a>. Once your Azure account is configured in Visual Studio right-click on the cloud project and select &lsquo;Publish&hellip;&rsquo;. </p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/metablogapi/4251.image_6DB7C0A6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-42-40-metablogapi/4251.image_5F00_6DB7C0A6.png"><img height="72" width="244" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/metablogapi/2117.image_thumb_4D9CB3E9.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-42-40-metablogapi/2117.image_5F00_thumb_5F00_4D9CB3E9.png" alt="image" border="0" title="image" style="background-image: none; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" /></a></p>
<p>Once the deployment is complete you can navigate to your cloudapp.net domain to see Jetty running. You will be greeted by the welcome page.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/metablogapi/2273.image_5B6EF9E4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-42-40-metablogapi/2273.image_5F00_5B6EF9E4.png"><img height="405" width="565" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/40/metablogapi/6724.image_thumb_1F432E3C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-42-40-metablogapi/6724.image_5F00_thumb_5F00_1F432E3C.png" alt="image" border="0" title="image" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" /></a></p>
<p>Remember Jetty defaults to the SelectChannelConnector showing your NIO application can run fine in Azure.</p>]]></content:encoded>
    </item>
  </channel>
</rss>