Deploying a Cloud Service to a VNet

In a recent post about Microsoft Azure Virtual Networks, I made the recommendation that Cloud Services should be deployed to Microsoft Azure Virtual Networks. The driving factor behind this recommendation comes from my personal real-world experience, where I learned the hard way, that moving a deployed Cloud Service to a Virtual Network meant downtime…

Getting it Done

In order to deploy a Cloud Service to a Virtual Network, we must add Network Configuration section to the Service Configuration file. The following is the updated ServiceConfiguration.Cloud.cscfg that specified that my Cloud Service is to be deployed to my Virtual Network called AzureVNet and more specifically to its Subnet called MiddleTier.

<?xml version="1.0" encoding="utf-16"?>
<ServiceConfiguration xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" serviceName="briseboisDemo3" osFamily="4" osVersion="*" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration">

  <Role name="Compute">
    <Instances count="5" />
  </Role>

  <NetworkConfiguration>
    <!-- Name of the target Virtual Network -->
    <VirtualNetworkSite name="AzureVNet" />

    <!-- Associating a Role to a Specific Subnet by name -->
    <AddressAssignments>
      <InstanceAddress roleName="Compute">
        <Subnets>
          <Subnet name="MiddleTier" />
        </Subnets>
      </InstanceAddress>
    </AddressAssignments>
  </NetworkConfiguration>
</ServiceConfiguration>

Looking at these configuration updates, you may be asking whether we have to do anything else to successfully deploy to a Virtual Network. The answer is no, there is nothing more to it. Fire up PowerShell or your favorite tool to deploy your updated Cloud Service package to Azure.

I used the following Network Configuration to create my test Virtual Network.

<?xml version="1.0" encoding="utf-8"?>
<NetworkConfiguration xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/ServiceHosting/2011/07/NetworkConfiguration">
  <VirtualNetworkConfiguration>
    <Dns />
    <VirtualNetworkSites>
      <VirtualNetworkSite name="AzureVNet" Location="East US 2">
        <AddressSpace>
          <AddressPrefix>10.0.0.0/24</AddressPrefix>
        </AddressSpace>
        <Subnets>
          <Subnet name="MiddleTier">
            <AddressPrefix>10.0.0.0/27</AddressPrefix>
          </Subnet>
        </Subnets>
      </VirtualNetworkSite>
    </VirtualNetworkSites>
  </VirtualNetworkConfiguration>
</NetworkConfiguration>

4 responses to Deploying a Cloud Services to A Virtual Network (VNet) on #Azure

  1. 

    Thanks Q

    Like

  2. 

    Hi Alexandre,
    thanks a lot for the sharing and globaly for the quality of the information you provide through this blog.
    i am currently try a proof of concept on how to deploy a Cloud service into a Vnet in order to address security issues. my question is to know once the cloud lives in a VNET is it still possible to deploy it from releaser manager ? like any paas resources ? any link or shared resource will be greatly appreciate.

    Like

  3. 

    Hi Alexandre,
    So what do you do if you want to have separate deployments to QA and Production environments? You can’t hard-code the network name, because QA and Prod will be on different networks…

    Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.