{"id":36942,"date":"2018-10-04T15:57:53","date_gmt":"2018-10-04T22:57:53","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/webdev\/?p=15455"},"modified":"2018-10-04T15:57:53","modified_gmt":"2018-10-04T22:57:53","slug":"use-hybrid-connections-to-incrementally-migrate-applications-to-the-cloud","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/use-hybrid-connections-to-incrementally-migrate-applications-to-the-cloud\/","title":{"rendered":"Use Hybrid Connections to Incrementally Migrate Applications to the Cloud"},"content":{"rendered":"<p>As the software industry shifts to running software in the cloud, organizations are looking to migrate existing applications from on-premises to the cloud. Last week at Microsoft\u2019s Ignite conference, <a href=\"https:\/\/twitter.com\/paulyuki99\">Paul Yuknewicz<\/a> and I delivered a talk focused on how to get started migrating applications to Azure (<a href=\"https:\/\/youtu.be\/2vp2ZCR6TbI\">watch the talk free<\/a>) where we walked through the business case for migrating to the cloud, and choosing the right hosting and data services. <a href=\"https:\/\/youtu.be\/2vp2ZCR6TbI?t=865\">If your application is a candidate for running in App Service<\/a>, one of the most useful pieces of technology that we showed was <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/biztalk-services\/integration-hybrid-connection-overview\">Hybrid Connections<\/a>. Hybrid Connections let you host a part of your application in Azure App Service, while calling back into resources and services not running in Azure (e.g. still on-premises). This enables you to try running a small part of your application in the cloud without the need to move your entire application and all of its dependencies at once; which is usually time consuming, and extremely difficult to debug when things don\u2019t work. So, in this post I\u2019ll show you how to host an ASP.NET front application in the cloud, and configure a hybrid connection to connect back to a service on your local machine.<\/p>\n<h2>Publishing Our Sample App to the Cloud<\/h2>\n<p>For the purposes of this post, I\u2019m going to use the <a href=\"https:\/\/github.com\/paulyuk\/modernizewithappservice\">Smart Hotel 360 App sample<\/a> that uses an ASP.NET front end that calls a WCF service which then accesses a SQL Express LocalDB instance on my machine. ** The first thing I need to do is publish the ASP.NET application to App Service. To do this, right click on the \u201cSmartHotel.Registration.Web\u201d project and choose \u201cPublish\u201d <a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/clip_image001.png\"><img decoding=\"async\" title=\"clip_image001\" alt=\"clip_image001\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/clip_image001_thumb.png\" width=\"513\" height=\"399\" border=\"0\" \/><\/a><\/p>\n<p>The publish target dialog is already on App Service, and I want to create a new one, so I will just click the \u201cPublish\u201d button. This will bring up the \u201cCreate App Service\u201d dialog.\u00a0 Next, I will click \u201cCreate\u201d and wait for a minute while the resources in the cloud are created and the application is published. <a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/clip_image003.jpg\"><img decoding=\"async\" title=\"clip_image003\" alt=\"clip_image003\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/clip_image003_thumb.jpg\" width=\"784\" height=\"588\" border=\"0\" \/><\/a> When it\u2019s finished publishing, my web browser will open to my published site. At this point, there will be an error loading the page since it cannot connect to the WCF service. To fix this we&#8217;ll add a hybrid connection. <a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/image35.png\"><img decoding=\"async\" title=\"image\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/image_thumb28.png\" width=\"1028\" height=\"241\" border=\"0\" \/><\/a><\/p>\n<h2>Create the Hybrid Connection<\/h2>\n<p>To create the Hybrid Connection, I navigate to the App Service I just created in the Azure Portal. One quick way to do this is to click the \u201cManaged in Cloud Explorer\u201d link on the publish summary page <a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/clip_image005.jpg\"><img decoding=\"async\" title=\"clip_image005\" alt=\"clip_image005\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/clip_image005_thumb.jpg\" width=\"679\" height=\"336\" border=\"0\" \/><\/a><\/p>\n<p>Right click the site, and choose \u201cOpen in Portal\u201d (You can manually navigate to the page by logging into <a href=\"https:\/\/portal.azure.com\/\">the Azure portal<\/a>, click App Services, and choose your site). <a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/clip_image0061.png\"><img decoding=\"async\" title=\"clip_image006\" alt=\"clip_image006\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/clip_image006_thumb1.png\" width=\"381\" height=\"319\" border=\"0\" \/><\/a><\/p>\n<p>To create the hybrid connection: Click the \u201cNetworking\u201d tab in the Settings section on the left side of the App Service page Click \u201cConfigure your hybrid connection endpoints\u201d in the \u201cHybrid connections\u201d section <a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/image36.png\"><img decoding=\"async\" title=\"image\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/image_thumb29.png\" width=\"946\" height=\"1054\" border=\"0\" \/><\/a> Next, click \u201cAdd a hybrid connection\u201d Then click \u201cCreate a new hybrid connection\u201d <a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/clip_image010.jpg\"><img decoding=\"async\" title=\"clip_image010\" alt=\"clip_image010\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/clip_image010_thumb.jpg\" width=\"689\" height=\"121\" border=\"0\" \/><\/a><\/p>\n<p>Fill out the \u201cCreate new hybrid connection\u201d form as follows: * <strong>Hybrid connection Name: **any unique name that you want**** * **Endpoint Host:<\/strong> This is the machine URL your application is currently using to connect to the on-premises resource. In this case, this is \u201clocalhost\u201d (*Note: per the documentation, use the hostname rather than a specific IP address if possible as it\u2019s more robust)***** * <strong>Endpoint Port: **The port the on-premises resource is listening on. In this case, the WCF service on my local machine is listening on 2901**** * **Servicebus namespace:<\/strong> If you\u2019ve previously configured hybrid connections you can re-use an existing one, in this case we\u2019ll create a new one, and give it a name****<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/clip_image011.png\"><img decoding=\"async\" title=\"clip_image011\" alt=\"clip_image011\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/clip_image011_thumb.png\" width=\"389\" height=\"525\" border=\"0\" \/><\/a><\/p>\n<p>**** Click \u201cOK\u201d. It will take about 30 seconds to create the hybrid connection, when it\u2019s done you\u2019ll see it appear on the Hybrid connections page.<\/p>\n<h3>Configure the Hybrid Connection Locally<\/h3>\n<p>Now we need to install the Hybrid Connection Manager on the local machine. To do this, click the \u201cDownload connection manager\u201d on the Hybrid connections page and install the MSI. **<a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/clip_image013.jpg\"><img decoding=\"async\" title=\"clip_image013\" alt=\"clip_image013\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/clip_image013_thumb.jpg\" width=\"599\" height=\"206\" border=\"0\" \/><\/a><\/p>\n<p>** After the connection manager finishes installing, launch the \u201cHybrid Connections Manager UI\u201d, it should appear in your Windows Start menu if you type \u201cHybrid Connections\u201d. (If for some reason it doesn\u2019t appear on the Start Menu, launch it manually from \u201cC:\\Program Files\\Microsoft\\HybridConnectionManager &lt;version#&gt;\u201d) Click the \u201cAdd a new Hybrid Connection\u201d button in the Hybrid Connections Manager UI and login with the same credentials you used to publish your application. <a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/clip_image015.jpg\"><img decoding=\"async\" title=\"clip_image015\" alt=\"clip_image015\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/clip_image015_thumb.jpg\" width=\"783\" height=\"139\" border=\"0\" \/><\/a> Choose the subscription you used published your application from the \u201cSubscription\u201d dropdown, choose the hybrid connection you just created in the portal, and click \u201cSave\u201d. <a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/clip_image017.jpg\"><img decoding=\"async\" title=\"clip_image017\" alt=\"clip_image017\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/clip_image017_thumb.jpg\" width=\"784\" height=\"441\" border=\"0\" \/><\/a> In the overview, you should see the status say \u201cConnected\u201d. *Note: If the state won\u2019t change from \u201cNot Connected\u201d, I\u2019ve found that rebooting my machine fixes this (it can take a few minutes to connect after the reboot). *<a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/clip_image019.jpg\"><img decoding=\"async\" title=\"clip_image019\" alt=\"clip_image019\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/clip_image019_thumb.jpg\" width=\"785\" height=\"489\" border=\"0\" \/><\/a> ** Make sure everything is running correctly on your local machine, and then when we open the site running in App Service we can see that it loads with no error. In fact, we can even put a breakpoint in the GetTodayRegistrations() method of Service.svc.cs, hit F5 in Visual Studio, and when the page loads in App Service the breakpoint on the local machine is hit! <a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/clip_image021.jpg\"><img decoding=\"async\" title=\"clip_image021\" alt=\"clip_image021\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/clip_image021_thumb.jpg\" width=\"784\" height=\"204\" border=\"0\" \/><\/a><\/p>\n<h2>Conclusion<\/h2>\n<p>If you are looking to move applications to the cloud, I hope that this quick introduction to Hybrid Connections will enable you to try moving things incrementally. If you are looking to migrate an application to the cloud, <a href=\"https:\/\/na01.safelinks.protection.outlook.com\/?url=http%3A%2F%2Fsurvey.usabilla.com%2Flive%2Fs%2F5b915c0bb07f2415534bbd48&amp;data=02%7C01%7Candrehal%40microsoft.com%7Cd071ab97fea54e6c11f708d62fd1dbed%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636748975724958399&amp;sdata=%2BNyw5keIecujcrgtNsbwFaZnkLe4HGwTTGFP0YMDZvk%3D&amp;reserved=0\">please tell us about it by taking this short survey<\/a>. Additionally, you may find these resources helpful: * Video: <a href=\"https:\/\/www.youtube.com\/watch?v=y_zAJZC_8Yk\">Azure App Service with Hybrid Connections to On-premises Resources<\/a> * <a href=\"https:\/\/myignite.techcommunity.microsoft.com\/sessions\/65905#ignite-html-anchor\">Watch our talk on migrating applications to Azure<\/a> * <a href=\"https:\/\/www.microsoft.com\/net\/apps\/cloud\/migrate-to-azure\">Migrate your .NET app to Azure<\/a> * <a href=\"https:\/\/www.microsoft.com\/net\/learn\/dotnet\/architecture-guides\">.NET application architecture guides<\/a> As always, if you have any questions, or problems let me know <a href=\"https:\/\/twitter.com\/AndrewBrianHall\">via Twitter<\/a>, or in the comments section below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As the software industry shifts to running software in the cloud, organizations are looking to migrate existing applications from on-premises to the cloud. Last week at Microsoft\u2019s Ignite conference, Paul Yuknewicz and I delivered a talk focused on how to get started migrating applications to Azure (watch the talk free) where we walked through the [&hellip;]<\/p>\n","protected":false},"author":404,"featured_media":21383,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[197,327,7252,7257],"tags":[31,37,7539,91,7576,7339],"class_list":["post-36942","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aspnet","category-azure","category-cloud","category-wcf","tag-asp-net","tag-azure","tag-cloud","tag-lift-and-shift","tag-migrate-to-the-cloud","tag-wcf"],"acf":[],"blog_post_summary":"<p>As the software industry shifts to running software in the cloud, organizations are looking to migrate existing applications from on-premises to the cloud. Last week at Microsoft\u2019s Ignite conference, Paul Yuknewicz and I delivered a talk focused on how to get started migrating applications to Azure (watch the talk free) where we walked through the [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/36942","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/404"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=36942"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/36942\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/21383"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=36942"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=36942"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=36942"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}