Skip to content

Commit 8478211

Browse files
Adding peer edit feedback.
1 parent ca2a316 commit 8478211

File tree

5 files changed

+77
-76
lines changed

5 files changed

+77
-76
lines changed
Loading

articles/service-bus-relay/service-bus-dotnet-hybrid-app-using-service-bus-relay.md

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,23 @@ ms.author: spelluru
1919
---
2020
# Expose an on-premises WCF service to a web application in the cloud by using Azure Relay
2121

22-
This article shows how to build a hybrid cloud application with Microsoft Azure and Visual Studio. You create an application that uses multiple Azure resources up and running in the cloud.
22+
This article shows how to build a hybrid cloud application with Microsoft Azure and Visual Studio. You create an application that uses multiple Azure resources in the cloud. This tutorial helps you learn:
2323

2424
* How to create or adapt an existing web service for consumption by a web solution.
2525
* How to use the Azure Windows Communication Foundation (WCF) Relay service to share data between an Azure application and a web service hosted elsewhere.
2626

27-
You take the following steps in this tutorial:
27+
You do the following tasks in this tutorial:
2828

2929
> [!div class="checklist"]
3030
>
31+
> * Install prerequisites for this tutorial.
3132
> * Review the scenario.
3233
> * Create a namespace.
33-
> * Create an on-premises server
34-
> * Create an ASP .NET application
34+
> * Create an on-premises server.
35+
> * Create an ASP .NET application.
3536
> * Run the app locally.
36-
> * Deploy the web app to Azure
37-
> * Run the app on Azure
37+
> * Deploy the web app to Azure.
38+
> * Run the app on Azure.
3839
3940
## Prerequisites
4041

@@ -46,42 +47,40 @@ To complete this tutorial, you need the following prerequisites:
4647

4748
## How Azure Relay helps with hybrid solutions
4849

49-
Business solutions are typically composed of a combination of custom code and existing functionality. Custom code tackles new and unique business requirements. Existing functionality is provided by solutions and systems that are already in place.
50+
Business solutions are typically composed of a combination of custom code and existing functionality. Custom code tackles new and unique business requirements. Solutions and systems that are already in place provide existing functionality.
5051

51-
Solution architects are starting to use the cloud for easier handling of scale requirements and lower operational costs. In doing so, they find that existing service assets they'd like to use as building blocks for their solutions are inside the corporate firewall and out of easy reach for access by the cloud solution. Many internal services aren't built or hosted in a way that they can be easily exposed at the corporate network edge.
52+
Solution architects are starting to use the cloud for easier handling of scale requirements and lower operational costs. In doing so, they find that existing service assets they'd like to use as building blocks for their solutions are inside the corporate firewall and out of easy reach by the cloud solution. Many internal services aren't built or hosted in a way that they can be easily exposed at the corporate network edge.
5253

53-
[Azure Relay](https://azure.microsoft.com/services/service-bus/) is designed for the use-case of taking existing WCF web services and making those services securely accessible to solutions that are outside the corporate perimeter without requiring intrusive changes to the corporate network infrastructure. Such relay services are still hosted inside their existing environment, but they delegate listening for incoming sessions and requests to the cloud-hosted relay service. Azure Relay also protects those services from unauthorized access by using [Shared Access Signature (SAS)](../service-bus-messaging/service-bus-sas.md) authentication.
54+
[Azure Relay](https://azure.microsoft.com/services/service-bus/) takes existing WCF web services and makes those services securely accessible to solutions that are outside the corporate perimeter without requiring intrusive changes to the corporate network infrastructure. Such relay services are still hosted inside their existing environment, but they delegate listening for incoming sessions and requests to the cloud-hosted relay service. Azure Relay also protects those services from unauthorized access by using [Shared Access Signature (SAS)](../service-bus-messaging/service-bus-sas.md) authentication.
5455

5556
## Review the scenario
5657

5758
In this tutorial, you create an ASP.NET website that enables you to see a list of products on the product inventory page.
5859

5960
![Scenario][0]
6061

61-
The tutorial assumes that you have product information in an existing on-premises system, and uses Azure Relay to reach into that system. This situation is simulated by a web service that runs in a simple console application and is backed by an in-memory set of products. You can run this console application on your own computer and deploy the web role into Azure. By doing so, you'll see how the web role running in the Azure datacenter calls into your computer. This call happens even though your computer will almost certainly be behind at least one firewall and a network address translation (NAT) layer.
62+
The tutorial assumes that you have product information in an existing on-premises system, and uses Azure Relay to reach into that system. A web service that runs in a simple console application simulates this situation. It contains an in-memory set of products. You can run this console application on your own computer and deploy the web role into Azure. By doing so, you'll see how the web role running in the Azure datacenter calls into your computer. This call happens even though your computer will almost certainly be behind at least one firewall and a network address translation (NAT) layer.
6263

6364
## Set up the development environment
6465

6566
Before you can begin developing Azure applications, download the tools and set up your development environment:
6667

6768
1. Install the Azure SDK for .NET from the SDK [downloads page](https://azure.microsoft.com/downloads/).
6869
1. In the **.NET** column, choose the version of [Visual Studio](https://www.visualstudio.com) you're using. This tutorial uses Visual Studio 2019.
69-
1. When prompted to run or save the installer, Select **Run**.
70-
1. In the **Web Platform Installer**, select **Install** and continue with the installation.
70+
1. When prompted to run or save the installer, select **Run**.
71+
1. In the **Web Platform Installer** dialog box, select **Install** and continue with the installation.
7172

72-
Once the installation is complete, you have everything necessary to start to develop the app. The SDK includes tools that let you easily develop Azure applications in Visual Studio.
73+
Once the installation is finished, you have everything necessary to start to develop the app. The SDK includes tools that let you easily develop Azure applications in Visual Studio.
7374

7475
## Create a namespace
7576

76-
The first step is to create a namespace, and to obtain a [Shared Access Signature (SAS)](../service-bus-messaging/service-bus-sas.md) key. A namespace provides an application boundary for each application exposed through the relay service. A SAS key is automatically generated by the system when a service namespace is created. The combination of service namespace and SAS key provides the credentials for Azure to authenticate access to an application.
77+
The first step is to create a namespace, and to obtain a [Shared Access Signature (SAS)](../service-bus-messaging/service-bus-sas.md) key. A namespace provides an application boundary for each application exposed through the relay service. An SAS key is automatically generated by the system when a service namespace is created. The combination of service namespace and SAS key provides the credentials for Azure to authenticate access to an application.
7778

7879
[!INCLUDE [relay-create-namespace-portal](../../includes/relay-create-namespace-portal.md)]
7980

8081
## Create an on-premises server
8182

82-
First, you build a simulated on-premises product catalog system. This project is a Visual Studio console application, and uses the [Azure Service Bus NuGet package](https://www.nuget.org/packages/WindowsAzure.ServiceBus/) to include the Service Bus libraries and configuration settings.
83-
84-
### Create the project
83+
First, you build a simulated on-premises product catalog system. This project is a Visual Studio console application, and uses the [Azure Service Bus NuGet package](https://www.nuget.org/packages/WindowsAzure.ServiceBus/) to include the Service Bus libraries and configuration settings. <a name="create-the-project"></a>
8584

8685
1. Start Microsoft Visual Studio as an administrator. To do so, right-click the Visual Studio program icon, and select **Run as administrator**.
8786
1. In Visual Studio, select **Create a new project**.
@@ -99,6 +98,9 @@ First, you build a simulated on-premises product catalog system. This project i
9998

10099
1. Add a new class for your product contract. In **Solution Explorer**, right-click the **ProductsServer** project and select **Add** > **Class**.
101100
1. In **Name**, enter the name *ProductsContract.cs* and select **Add**.
101+
102+
Make the following code changes to your solution:
103+
102104
1. In *ProductsContract.cs*, replace the namespace definition with the following code, which defines the contract for the service.
103105

104106
```csharp
@@ -228,7 +230,7 @@ First, you build a simulated on-premises product catalog system. This project i
228230
</appSettings>
229231
```
230232

231-
1. Press Ctrl+Shift+B or select **Build** > **Build Solution** to build the application and verify the accuracy of your work so far.
233+
1. Select Ctrl+Shift+B or select **Build** > **Build Solution** to build the application and verify the accuracy of your work so far.
232234

233235
## Create an ASP.NET application
234236

@@ -249,7 +251,7 @@ In this section, you build a simple ASP.NET application that displays data retri
249251
![Specify authentication][18]
250252

251253
1. Back in **Create a new ASP.NET Web Application**, select **Create** to create the MVC app.
252-
1. Configure Azure resources for a new web app. Follow the steps in the [Publish to Azure section of this article](../app-service/app-service-web-get-started-dotnet-framework.md#launch-the-publish-wizard). Then, return to this tutorial and continue to the next step.
254+
1. Configure Azure resources for a new web app. Follow the steps in [Publish your web app](../app-service/app-service-web-get-started-dotnet-framework.md#launch-the-publish-wizard). Then, return to this tutorial and continue to the next step.
253255
1. In **Solution Explorer**, right-click **Models** and then select **Add** > **Class**.
254256
1. Name the class *Product.cs*, then select **Add**.
255257

@@ -337,14 +339,14 @@ In this section, you build a simple ASP.NET application that displays data retri
337339
</table>
338340
```
339341

340-
1. To verify the accuracy of your work so far, you can press Ctrl+Shift+B to build the project.
342+
1. To verify the accuracy of your work so far, you can select Ctrl+Shift+B to build the project.
341343

342344
### Run the app locally
343345

344346
Run the application to verify that it works.
345347

346348
1. Ensure that **ProductsPortal** is the active project. Right-click the project name in **Solution Explorer** and select **Set As Startup Project**.
347-
1. In Visual Studio, press **F5**.
349+
1. In Visual Studio, select F5.
348350

349351
Your application should appear, running in a browser.
350352

@@ -355,14 +357,14 @@ Your application should appear, running in a browser.
355357
The next step is to hook up the on-premises products server with the ASP.NET application.
356358

357359
1. If it isn't already open, in Visual Studio, open the **ProductsPortal** project you created in the [Create an ASP.NET application](#create-an-aspnet-application) section.
358-
1. Similar to the step in the [Create an On-Premises Server](#create-an-on-premises-server) section, add the NuGet package to the project references. In **Solution Explorer**, right-click the **ProductsPortal** project, then select **Manage NuGet Packages**.
359-
1. Search for *WindowsAzure.ServiceBus* and select the **WindowsAzure.ServiceBus** item. Then complete the installation and close this dialog box.
360+
1. Similar to the step in the [Create an on-premises server](#create-an-on-premises-server) section, add the NuGet package to the project references. In **Solution Explorer**, right-click the **ProductsPortal** project, then select **Manage NuGet Packages**.
361+
1. Search for *WindowsAzure.ServiceBus* and select the **WindowsAzure.ServiceBus** item. Then finish the installation and close this dialog box.
360362
1. In **Solution Explorer**, right-click the **ProductsPortal** project, then select **Add** > **Existing Item**.
361363
1. Navigate to the *ProductsContract.cs* file from the **ProductsServer** console project. Highlight *ProductsContract.cs*. Select the down arrow next to **Add**, then choose **Add as Link**.
362364

363365
![Add as a link][24]
364366

365-
1. Now open the *HomeController.cs* file in the Visual Studio editor and replace the namespace definition with the following code. Be sure to replace `yourServiceNamespace` with the name of your service namespace, and `yourKey` with your SAS key. This code enables the client to call the on-premises service, returning the result of the call.
367+
1. Now open the *HomeController.cs* file in the Visual Studio editor and replace the namespace definition with the following code. Be sure to replace `yourServiceNamespace` with the name of your service namespace, and `yourKey` with your SAS key. This code lets the client to call the on-premises service, returning the result of the call.
366368

367369
```csharp
368370
namespace ProductsWeb.Controllers
@@ -412,20 +414,19 @@ The next step is to hook up the on-premises products server with the ASP.NET app
412414
![Multiple startup projects][25]
413415

414416
1. Select **Common Properties** > **Project Dependencies** on the left side.
415-
1. For **Projects**, choose **ProductsServer**. Ensure that **ProductsPortal** isn't selected.
416417
1. For **Projects**, choose **ProductsPortal**. Ensure that **ProductsServer** is selected.
417418

418419
![Project dependencies][26]
419420

420-
1. Select **OK** to save your changes.
421+
1. For **Projects**, choose **ProductsServer**. Ensure that **ProductsPortal** isn't selected, and then select **OK** to save your changes.
421422

422423
## Run the project locally
423424

424-
To test the application locally, in Visual Studio press **F5**. The on-premises server, **ProductsServer**, should start first, then the **ProductsPortal** application should start in a browser window. This time, you see that the product inventory lists data retrieved from the product service on-premises system.
425+
To test the application locally, in Visual Studio select F5. The on-premises server, **ProductsServer**, should start first, then the **ProductsPortal** application should start in a browser window. This time, you see that the product inventory lists data retrieved from the product service on-premises system.
425426

426427
![Web application][10]
427428

428-
Press **Refresh** on the **ProductsPortal** page. Each time you refresh the page, you see the server app display a message when `GetProducts()` from **ProductsServer** is called.
429+
Select **Refresh** on the **ProductsPortal** page. Each time you refresh the page, you see the server app display a message when `GetProducts()` from **ProductsServer** is called.
429430

430431
Close both applications before proceeding to the next section.
431432

@@ -439,15 +440,13 @@ The next step is to republish the Azure Web app **ProductsPortal** front end:
439440
> You may see an error message in the browser window when the **ProductsPortal** web project is automatically launched after the deployment. This is expected, and occurs because the **ProductsServer** application isn't running yet.
440441
>
441442

442-
1. Copy the URL of the deployed web app. You'll need the URL later. You can also obtain this URL from the **Azure App Service Activity** window in Visual Studio:
443+
1. Copy the URL of the deployed web app. You'll need the URL later. You can also get this URL from the **Azure App Service Activity** window in Visual Studio:
443444

444445
![URL of the deployed app][9]
445446

446447
1. Close the browser window to stop the running application.
447448

448-
### Set ProductsPortal as web app
449-
450-
Before running the application in the cloud, you must ensure that **ProductsPortal** is launched from within Visual Studio as a web app.
449+
<a name="set-productsportal-as-web-app"></a>Before running the application in the cloud, you must ensure that **ProductsPortal** is launched from within Visual Studio as a web app.
451450

452451
1. In Visual Studio, right-click the **ProductsPortal** project and select **Properties**.
453452
1. Select **Web**. Under **Start Action**, choose **Start URL**. Enter the URL for your previously deployed web app, in this example, `https://productsportal20190906122808.azurewebsites.net/`.
@@ -459,19 +458,19 @@ Before running the application in the cloud, you must ensure that **ProductsPort
459458

460459
## Run the application
461460

462-
Press **F5** to build and run the application. The on-premises server, which is the **ProductsServer** console application, should start first, then the **ProductsPortal** application should start in a browser window, as shown here:
461+
Select F5 to build and run the application. The on-premises server, which is the **ProductsServer** console application, should start first, then the **ProductsPortal** application should start in a browser window, as shown here:
463462

464463
![Run the web app on Azure][1]
465464

466465
The product inventory lists data retrieved from the product service on-premises system, and displays that data in the web app. Check the URL to make sure that **ProductsPortal** is running in the cloud, as an Azure web app.
467466

468467
> [!IMPORTANT]
469-
> The **ProductsServer** console application must be running and able to serve the data to the **ProductsPortal** application. If the browser displays an error, wait a few more seconds for **ProductsServer** to load and display the following message. Then press **Refresh** in the browser.
468+
> The **ProductsServer** console application must be running and able to serve the data to the **ProductsPortal** application. If the browser displays an error, wait a few more seconds for **ProductsServer** to load and display the following message, then refresh the browser.
470469
>
471470

472-
In the browser, press **Refresh** on the **ProductsPortal** page. Each time you refresh the page, you see the server app display a message when `GetProducts()` from **ProductsServer** is called.
471+
In the browser, refresh the **ProductsPortal** page. Each time you refresh the page, you see the server app display a message when `GetProducts()` from **ProductsServer** is called.
473472

474-
![Updated output][38]
473+
![Updated output][38]
475474

476475
## Next steps
477476

@@ -493,7 +492,7 @@ Advance to the following tutorial:
493492
[9]: ./media/service-bus-dotnet-hybrid-app-using-service-bus-relay/web-publish-activity.png
494493
[10]: ./media/service-bus-dotnet-hybrid-app-using-service-bus-relay/run-web-app-locally.png
495494

496-
[21]: ./media/service-bus-dotnet-hybrid-app-using-service-bus-relay/App1.png
495+
[21]: ./media/service-bus-dotnet-hybrid-app-using-service-bus-relay/run-web-app-locally-no-content.png
497496
[24]: ./media/service-bus-dotnet-hybrid-app-using-service-bus-relay/add-existing-item-link.png
498497
[25]: ./media/service-bus-dotnet-hybrid-app-using-service-bus-relay/hy-web-13.png
499498
[26]: ./media/service-bus-dotnet-hybrid-app-using-service-bus-relay/hy-web-14.png

0 commit comments

Comments
 (0)