Screenshot from 2014-05-22 22:43:45

Ah, Windows Azure. Can’t put more that one NIC on a VM. A VNETs can’t talk to each other. No web-based virtual display or console for your VM, so a VM must have a working TCP/IP connection. The list goes on. That being said, Microsoft’s approach to cloud service is quite different from others, and while it lacks these seemingly standard features, compared to its’ contemporaries such as VMWare VDC, Azure management portal is extremely easy to use. You can build VMs, web servers with your preferred CMS, and even service buses, with a couple of mouse clicks.

Now, on to today’s topic. As you might have notice, when you create a cloud service node, the wizard does not provide an option to attach the node to a virtual network that you have on your azure subscription. However , this can be done by directly editing the service configuration file. First, navigate your management portal to the cloud service node, go to the configuration tab, and select either production or staging deployment. At the bottom of the screen there’s a button to download the currently active service configuration file

download

You should have with you a ServiceConfiguration.cscfg file. Open the file with your preferred text editor

<?xml version="1.0" encoding="utf-8"?>
<!--
  **********************************************************************************************

  This file was generated by a tool from the project file: ServiceConfiguration.Cloud.cscfg

  Changes to this file may cause incorrect behavior and will be lost if the file is regenerated.

  **********************************************************************************************
-->
<ServiceConfiguration serviceName="TestBAF" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="1" osVersion="*">
    <Role name="ThatTestSite">
        <Instances count="1" />
        <ConfigurationSettings>
            <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
        </ConfigurationSettings>
    </Role> 
</ServiceConfiguration>

Add the network configuration setting inside the <ServiceConfiguration>, after </Role>. The service configuration file should look like this

<?xml version="1.0" encoding="utf-8"?>
<!--
  **********************************************************************************************

  This file was generated by a tool from the project file: ServiceConfiguration.Cloud.cscfg

  Changes to this file may cause incorrect behavior and will be lost if the file is regenerated.

  **********************************************************************************************
-->
<ServiceConfiguration serviceName="ThisTestService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="1" osVersion="*">
    <Role name="ThatTestSite">
        <Instances count="1" />
        <ConfigurationSettings>
            <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
        </ConfigurationSettings>
    </Role>
    <NetworkConfiguration>
        <VirtualNetworkSite name="INT001" />
        <AddressAssignments>
            <InstanceAddress roleName="ThatTestSite">
                <Subnets>
                    <Subnet name="Subnet-1" />
                </Subnets>
            </InstanceAddress>
        </AddressAssignments>
    </NetworkConfiguration> 
</ServiceConfiguration>

Virtual Network Site and subnet should refer to the virtual network and subnet where the cloud service node should reside. Instance Address role name  should be pointed to the role name of that particular service configuration. Save, and the new configuration is now ready to applied. On the configuration page, tap the upload button to upload the new ServiceConfiguration.cscfg

upload

You can’t download and upload ServiceConfiguration.cscfg on an already deployed/running services. To add virtual network configuration to an already deployed or running service, make the change on Visual Studio’s package and push it to the Azure service.

To check whether it’s working, go to the network tab and select the virtual network that hosts the cloud service node, see if the cloud service node is listed on

ThatTest

…And done!

By ikhsan

2 thoughts on “Adding a Windows Azure Cloud Service to virtual network”

Leave a Reply

Your email address will not be published. Required fields are marked *

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