![]() |
|
Exploring Azure App Service – Web Apps and SQL Azure - Printable Version +- Sick Gaming (https://sickgaming.net) +-- Forum: Programming (https://sickgaming.net/forum-76.html) +--- Forum: C#, Visual Basic & .NET (https://sickgaming.net/forum-79.html) +--- Thread: Exploring Azure App Service – Web Apps and SQL Azure (/thread-85113.html) |
Exploring Azure App Service – Web Apps and SQL Azure - xSicKxBot - 06-07-2018 Exploring Azure App Service – Web Apps and SQL Azure There is a good chance that your web app uses a database. In my previous post introducing Azure App Service, I showed some of the benefits of hosting apps in Azure App Service, and how easy it is to get a basic site running in a few clicks. In this post I’ll show how to set up a SQL Azure database along with an App Service Web App from Visual Studio, and apply Entity Framework automatically as part of publish. Let’s get going To get started, you’ll first need:
I can now run my project locally (F5) and create user accounts which will be stored in a SQL Server Express Local DB on my machine. Publishing to App Service with a Database Let’s publish our application to Azure. To do this, I’ll right click my project in Solution Explorer and choose “Publish” This brings up the Visual Studio publish target dialog, which will default to the Azure App Service pane with the “Create new” radio button selected. To continue click “Publish”. This brings up the “Create App Service” dialog (see the “Key App Service Concepts” section of my previous post for an explanation of the fields). To create a SQL Database for our app to use, click the “Create a SQL Database” link in the top right section of the dialog. This will bring up the “Configure SQL Database” dialog.
It should take ~2-3 minutes to create all of the resources in Azure, then your application will publish and a browser will open to your home page. Configuring EF Migrations At this point there is a database for your app to use in the cloud, but EF migrations have not been applied, so any functionality that relies on the database (e.g. Registering for a user account) will result in an error. To apply EF migrations to the database:
That’s it, your web app and SQL Azure database are both configured and running in the cloud. Conclusion Hopefully, this post showed you how easy it is to try App Service and SQL Azure. We believe that for most people, App Service is the easiest place to get started with cloud development, even if you need to move to other services in the future for further capabilities (compare hosting options). As always, let us know if you run into any issues, or have any questions below or via Twitter. |