As a cloud first, mobile first IDE, Visual Studio for Mac is designed to work side by side with Azure. In this post, you’ll create an ASP.NET Core project, edit the site to be unique, and then deploy the project to Azure. To complete this task, make sure your setup meets the following requirements:
- Visual Studio for Mac 7.2.x or greater
- .NET Core 2 (If you do not have .NET Core 2, you can download the latest version from the .NET Core site)
- An Azure account (If you do not have an Azure account, you can sign up for free today!)
With those prerequisites in place, you can get started on an ASP.NET Core app. Remember, you can do this all from Visual Studio for Mac, so close Terminal and forget about FTP. To get started, open Visual Studio for Mac and click “New Project”. On the New Project screen, select .NET Core > App > ASP.NET Core Web App and follow the prompts to name your project.
After the project is created, you’ll edit the HTML to truly make it your own unique project. Within Visual Studio for Mac, expand Views > Home and open About.cshtml. Feel free to edit this page in any small way you see fit. For this example, I changed the “About” text to, “This was created by a tutorial on the Xamarin Blog!”
At this point, save the project and deploy it to Azure. If you do not have an account, now is a great time to create a free one on Azure. Once you have the account created, right-click or ctrl-click on your project and select Publish > Publish to Azure.
If you’re not already logged in to Visual Studio for Mac, log in via the publishing tool. Once logged in, you’ll be greeted by a window like this:
If you’re already an Azure user, you may see a list of existing app services. You need to create a new one for this exercise, so please click “New” on the bottom left. This will take you to the “New App Service” screen, where you need to fill in the pertinent information for your project. Once you’re ready, the “Create” button should be active:
If the “Create” button isn’t active, be sure to check that all fields are populated and that the name you select is available. If the name you selected is not available, you may see an exclamation point near the name field. Once everything is in order, you should be able to click the “Create” button; go ahead and see what happens!
A warning should appear letting you know that this may take some time, which you can dismiss. Then, you’ll see the following info bar messages:
Once published, your newly deployed ASP.NET Core Web App should open in your default browser!
In this post, you learned how to create and publish an ASP.NET Core Web App to Azure using nothing but Visual Studio for Mac. We’re excited to be adding Azure integration directly into the IDE, and we hope you enjoy using it.
Discuss this blog post on our forum!