Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Microsoft Azure Development Cookbook Second Edition

You're reading from   Microsoft Azure Development Cookbook Second Edition Over 70 advanced recipes for developing scalable services with the Microsoft Azure platform

Arrow left icon
Product type Paperback
Published in Sep 2014
Publisher
ISBN-13 9781782170327
Length 422 pages
Edition 1st Edition
Tools
Concepts
Arrow right icon
Toc

Table of Contents (10) Chapters Close

Preface 1. Developing Cloud Services for Microsoft Azure 2. Deploying Quickly with Azure Websites FREE CHAPTER 3. Getting Storage with Blobs in Azure 4. Going Relational with the Azure SQL Database 5. Going NoSQL with Azure Tables 6. Messaging and Queues with the Storage and Service Bus 7. Managing Azure Resources with the Azure Management Libraries 8. Going In-memory with Azure Cache Index

Publishing a Cloud Service with options from Visual Studio

Microsoft Azure always shipped with an SDK for developers and a complementary toolset for Visual Studio integration. In earlier versions of the official SDK, many features were only available through the online portal at https://manage.windowsazure.com. At the time of writing this book, Microsoft released its major SDK update that lets developers quickly manage almost everything of the cloud infrastructure directly from Visual Studio. Hence, it is now simpler to get on Azure and run a Cloud Service compared to the past.

When we publish a Cloud Service into Azure, we should know some foundation concepts in advance, in order to understand the ecosystem better. First, to deploy a Cloud Service, a deployment slot should be created. This could be done through the portal or from Visual Studio, and it consists of creating a DNS name in [myCS].cloudapp.net form. This DNS, under the hood, is linked to a load balancer that actually redirects the Internet traffic to the CS, to each instance of our service, choosing it with a round-robin algorithm. This means that regardless of the topology, we are deploying to Azure in this Cloud Service. Every web endpoint that we are publishing stands behind this layer of balancing to provide the system with transparent scaling capabilities.

During the deployment, we also decide the options that CS should be deployed with:

  • Production/staging slot
  • Remote desktop support
  • Diagnostics collection
  • Remote debugging
  • IntelliTrace support
  • Incremental/simultaneous update

After we perform the deployment, our service, comprehensive of all the roles of the package, as defined in the Setting up solutions and projects to work with Cloud Services recipe, is running in the cloud and is accessible through the DNS name Azure provided us.

Getting ready

For this recipe, we can create a sample solution on the fly by navigating to File | New project | Cloud wizard or using the WAHelloWorld project created earlier.

How to do it…

We are going to see how to deploy a Cloud Service package to the cloud. We can do this by performing the following steps:

  1. Right-click on the Azure wrapper project (WAHelloWorld) and select Publish.
  2. In the Publish Microsoft Azure Application window, click on Sign In to authenticate.
  3. In the browser window, enter the credentials of the Microsoft Account (former Live ID) associated with the Azure account and continue.
  4. In the Choose your subscription dropdown, choose the subscription that will host your service.
  5. If your subscription is empty or it does not contain a Cloud Service, you will be prompted with the Create Microsoft Azure Services window.
  6. Enter a name into the Name box, and choose a location for your service.
  7. In the Cloud Service dropdown, choose the Cloud Service to which you want your service to be deployed.
  8. In the Environment dropdown, choose Production.
  9. In the Service configuration dropdown, choose Cloud.
  10. In the Build configuration dropdown, choose the correct build configuration, according to the ones available in your service (in the WAHelloWorld example, choose Release).

    Note

    Configuring the remote desktop is optional.

  11. Check on the Enable Remote Desktop for all roles checkbox.
  12. In the Remote Desktop Configuration window, specify a username, a password, and a date for account expiration. Then, click on OK.

    Tip

    Using RDP on Microsoft Azure is not recommended due to the nature of PaaS services. It is recommended that you use it only for dev/test purposes and rely on external or active monitoring to troubleshoot and resolve issues.

    Note

    The advanced settings tab is optional.

  13. Specify WAHelloWorld Version 1 in the Deployment label box.
  14. Leave the Append current date and time checkbox unchecked.
  15. If your subscription is empty or it does not contain a storage account, you will be prompted with the Create Microsoft Azure Services window.
  16. Enter a name into the Name box, and choose a location for your service.
  17. In the Storage account dropdown, choose the storage account where Visual Studio will upload the package file, letting Azure deploy it from the Blob storage.
  18. Uncheck every checkbox except the Deployment update one, then click on Settings.
  19. In the Deployment settings window, select Incremental update.
  20. Check the If deployment can't be updated, do a full deployment checkbox and confirm.

    Note

    Conclusion.

  21. Next, in the Summary page of the wizard, check all the information and then save your publish profile file.
  22. Click on Publish.
  23. After few or several minutes (it depends on the size of your deployment), check the Microsoft Azure Activity Log tab in VS for completion of the deployment process.
  24. At completion, if your service has a role with a valid HTTP endpoint, navigate to it at http://[nameOfCloudService].cloudapp.net.

How it works…

Up to step 3, we link VS with our Microsoft Account (formerly, Live ID). As a Microsoft account could be the administrator and co-administrator of multiple Azure subscriptions at the same time, after the authentication, the dropdown mentioned in step 4 could be a pretty long list of entries.

In step 5, we create a Cloud Service on the Azure platform; this means that we create the deployment slots (one for production, one for staging) to run our service. Every time we create a service in the Azure platform, we must cope with the localization of the service, in terms of the choice of a datacenter. There are actually about 13 datacenters, plus one in China:

  • Europe North: Ireland
  • Europe West: Netherlands
  • US Central: Iowa
  • US East: Virginia
  • US East 2: Virginia
  • US West: California
  • US North Central: Illinois
  • US South Central: Texas
  • Asia Pacific East: Hong Kong
  • Asia Pacific Southeast: Singapore
  • Japan East: Saitama Prefecture
  • Japan West: Osaka Prefecture
  • Brazil South: Sao Paulo State

    Tip

    Two new datacenters in Australia have also been announced, but not yet released to the public.

In steps 7 and 8, we chose which slot to use for deployment and which configuration to publish for it. For each new Cloud Service project, VS creates two service configuration files: a local one and a cloud one.

In step 9, we choose the build configuration. This step is related to the actual build settings of our solution. In the new solution, there are just two configurations (debug/release), but the list could be longer according to real-life projects and complexity.

In steps 10 and 11, we configured the remote desktop. Though this is not recommended, this could let us connect to each instance to troubleshoot any issues and master the OS configuration of an Azure Virtual Machine image. Due to security implications in this process, a self-signed certificate is generated automatically to establish the TLS connection. It is also possible to provide our own valid certificate by clicking on More Options in the Remote Desktop Configuration window.

Tip

We learned that in Azure, we have many instances behind a single load balancer (therefore, a single IP) to RDP the instances we must proceed one-by-one with different combinations of ip:port.

Steps 12 and 13 were straightforward. They indicated the name of the deployment for further administrative tasks.

In steps 14 and 15, we chose a storage account. As we never talked about this feature earlier in the book, just keep in mind that a Cloud Service could be connected to a storage account to provide it with logging and diagnostics data.

From steps 16 to 18, we set up the options for update. As Azure could have a previous online version of our service, we had to decide how to manage the update. By unchecking the Deployment update checkbox, we completely bypassed the update process, telling Azure to delete the old deployment because a new one was going to arrive. Otherwise, we can specify how to update the service, gracefully (incremental update) or suddenly (simultaneously update). In the incremental update, Azure updates a service instance by instance, theoretically without service interruption. On the other hand, Azure updates every instance at the same time, causing an interruption of the service. In some cases, a deployment could not be updated. If this is the case, then perform a delete-and-replace operation.

In step 19, we saved the publish settings to use them later, thus avoiding repeating all the steps, by directly clicking on Publish from the summary pane. In step 21, we recognized the VS-integrated progress window, refreshed periodically from an Azure service. We can also use it to stop/cancel pending operations, as it reflects the portal operations.

There's more…

If we checked the Enable Remote Desktop for all roles checkbox during the publishing process, it is possible to connect to each instance directly from Visual Studio using the following steps:

  1. Locate the Microsoft Azure node in the Server Explorer.
  2. Locate the Cloud Services subnode and the Cloud Service you want to connect to (in the example, WAHelloWorld).
  3. Expand the node, and select the production or staging deployment.
  4. Expand the node and the role of interest; it will show a list of the deployed instance.

    Tip

    This list, as for the list of Cloud Services and related roles, could depend on the actual running configuration of your service. Remember that a Cloud Service can contain many roles, and each role can have many instances.

  5. Right-click on the selected instance (from instance 0 to instance "N"), and choose Connect using Remote Desktop….
  6. Confirm the settings in the Remote Desktop Connection window and enter the VM. If prompted with a credential set (in most cases, only for the password), type the ones you gave in the publishing process.
  7. You are now connected to a real running instance of Azure.

    Tip

    While connected to the real instance of Azure, you can poke around the OS, observing the following:

    • The filesystem topology (the C: / D: / E)
    • The virtualized hardware (processor, RAM, and so on)
    • The network settings (internal IP, gateway, and so on)

We cannot actually rely on the information we gain by browsing the VM, as it is subject to change frequently without control by the user.

See also

Have a look at the following MSDN links to get additional information:

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime