Share via


Walkthrough: Creating a Cross-Platform Web Application using Visual Studio

This walkthrough shows how to develop an ASP.NET 5 web application using Visual Studio 2015 RC, and then deploy it to a Linux server on Azure.

Prerequisites

The following prerequisites are required and will be installed as part of the walkthrough.

  • Visual Studio 2015 RC

  • The Parts Unlimited sample application.

  • A .NET Core Linux VM on Azure (Azure subscription required)

Acquire

The procedures in this section will set up everything you need on Windows and on Azure.

Install Visual Studio 2015 RC

  1. Go to Visual Studio 2015 RC and download Visual Studio 2015 RC.

  2. Follow the instructions to install Visual Studio 2015 RC.

    The default installation contains the .NET Core and ASP.NET 5 libraries necessary for this walkthrough.

  3. Install Microsoft Web Platform Installer.

  4. When Web Platform Installer opens, choose the Add button for Microsoft Azure SDK for .NET (VS 2015) - 2.6.

  5. Choose the Install button and follow the prompts to complete the installation.

Set up a .NET Core Linux VM on Azure

  1. Log in to your Microsoft Azure portal.

    If you don’t have an Azure subscription, you can get a trial subscription here: Free one-month trial.

  2. On the portal page, choose the VIRTUAL MACHINES node, and then choose the IMAGES link.

  3. Choose the BROWSE VM DEPOT link to open the BROWSE VM DEPOT wizard.

  4. In the wizard on the Choose an Image page, expand the Visual Studio node and choose the CoreCLR x64 Beta5 (11624) with PartsUnlimited Demo App image, and then choose the Next button.

  5. On the Virtual machine configuration page, in the VIRTUAL MACHINE NAME field, enter a unique name for your VM.

  6. Clear the UPLOAD COMPATIBLE SSH KEY FOR AUTHENTICATION checkbox, select the PROVIDE A PASSWORD checkbox, enter a password and then choose the Next button.

  7. In the ENDPOINTS section, open the ENTER OR SELECT A VALUE list and choose HTTP.

  8. In the PUBLIC PORT and PRIVATE PORT fields enter 5004.

  9. Choose the Next button, and then choose the Complete button to create the VM.

    It may take several minutes to create the VM. When the Status field displays Running you can continue the walkthrough.

Develop

For this walkthrough you will create an ASP.NET 5 web application in Visual Studio. You could just as easily create the app on a Macintosh computer using Visual Studio Code for OS X, if that’s your preference.

Load the project

  1. In Visual Studio, on the menu bar, choose View, Team Explorer.

  2. In the Team Explorer window, on the ToolBar choose the Manage Connections button, and then in the Local Git Repositories section expand the Clone dropdown.

  3. In the Enter the URL of a Git repo to clone text box, enter https://github.com/Microsoft/PartsUnlimited.git, and then choose the Clone button.

    Once the clone is complete, PartsUnlimited and the path to the repository will appear in the Local Git Repositories list.

  4. On the Toolbar choose the Home button, and in the Solutions list open the shortcut menu for the PartsUnlimited.sln file and choose Open.

  5. After opening the solution, wait for the Output window Package Manager pane to show "Restore complete" and "Total time" messages.

    Note

    This may take several minutes.

  6. On the menu bar, choose Debug, Start Debugging to run the application.

Deploy

The final step is to deploy the application to the Linux VM on Azure. Deployment will be accomplished via a Docker command in Visual Studio. This is not yet implemented in Visual Studio 2015 RC. A version of the Parts Unlimited application is included in the CoreCLR x64 Beta5 (11624) with PartsUnlimited Demo App VM, and you can run the application by accessing it on the Linux server.

Run the application from the Linux server on Azure

  1. Open a SSH client on the machine from which you want to access the application. This walkthrough uses PuTTY. Several other clients are available for Windows and for Linux.

  2. In the Microsoft Azure portal, open the Dashboard for the CoreCLR x64 Beta5 (11624) with PartsUnlimited Demo App VM and note the value of the SSH details field.

  3. In PuTTY, enter the values from the SSH details field in the Host Name and Port fields, and then choose the Open button to launch a Linux terminal.

  4. In the terminal, at the login prompt, enter azureuser as the user name, and enter the password that you provided when creating the VM.

  5. At the ~$ prompt, enter /opt/demo/Kestrel and wait until the terminal returns Started.

  6. In a web browser, enter the URL https://<your-host-name>.cloudapp.net:5004, where <your-host-name> is the name of the Linux VM.

    Verify that the application looks and acts exactly the same running on a Linux server as it did running on Windows.

Next Steps

The CoreCLR for cross-platform development is still in an early preview stage with many more changes to come. If you want to try out other scenarios, you can run the Parts Unlimited sample app on a Mac (see Walkthrough: Running a Cross-Platform Web Application on OS X) or even create your own ASP.NET app using Visual Studio Code for OS X.

See Also

Other Resources

Create Cross-Platform .NET Apps