Ops / IT Pro
The course is part of these learning paths
There's a lot of effort that goes into keeping our applications available, and secure. That's why so many cloud vendors offer platforms for hosting web-based applications. If you're building web apps, APIs, mobile backends, or business processes then you should consider looking into App Service! App Service has a lot of functionality. It meets compliance standards from around the world, it's highly scalable, it supports multiple languages and makes it easy to get your code deployed.
This Getting Started with Azure App Service course it's basically an intro, but for developers and IT Pros. In this course, you'll learn about the features of App Service at a high level as well as for each component. Then you'll learn about each of the 4 components of App Service through some demos. If you're a developer or IT Pro working with Azure, but new to App Service, this course is for you.
This course will help get you up-to-speed on App Service so that you can start developing / managing apps.
Getting Started With Azure App Service: What You'll Learn
|Lecture||What you'll learn|
|Course Intro||What to expect from this course|
|App Service Overview||A high-level overview of App Service|
|Web, Mobile, API App Overview||A high-level overview of Web, Mobile, API Apps|
|Logic App Overview||A high-level overview of Logic Apps|
|Mobile Apps: Easy Tables||How to use Easy Tables as a "no-code" option|
|Mobile Apps: Client||Running the client code from an iOS simulator|
|Mobile Apps: .NET Backend||Using a .NET backend|
|Mobile Apps: Auth||Using authentication with App Service|
|API Apps||Creating API Apps|
|Logic Apps||Automating business processes|
|Web Apps||Authentication and remote debugging|
|Deployments||Deployment slots and GitHub based deployments|
|Monitoring and Logging||Monitoring and logging options|
|Scaling||Scaling up and out|
|Next Steps||What's next|
Welcome back! In the previous lessons we saw how to get started with mobile apps using the Node.js backend supplied by Easy Tables. However, for a lot of us, we’ll be using a .NET backend and managing database schema changes for ourselves.
So, let’s run through the todo app again, however let’s use a .NET backend. We’ll use the same Xamarin iOS app on the client side, so we can focus on the differences with the back-end.
We already have the TodoItem table created as an Easy Table, so before we get started, let’s delete it.
To do that open up the Easy Tables blade, and click on the todoitem. Then under “more” click delete, then confirm the deletion, and we’re all set.
Now that we no longer have a todoitem table, we can setup a .NET backend. There are a few ways to do that. Let’s cover two ways to get started, the first is that we can go back to the quickstart.
Recall that for step 2 we previously used a Node.js backend and it used Easy Tables. So, now we can switch from Node.js to C#, notice the download button that appears. This will download a zip file containing a Visual Studio solution.
So this is one way to get a solution up-and-running. However if you’re using a recent version of Visual Studio then you can use the Azure Mobile template to create a backend.
Let’s check that out.
From inside Visual Studio click on More Templates under the New project section. If you’re not seeing it in the list, you can search on the top right. Since I have it here, I’ll click on this one, the Azure Mobile - C# version, and then give it a name.
Notice on the side here, that Authentication is disabled; that’s because App Service provides authentication so you don’t need to manage it for yourself. That’s not to say you can’t implement your own. However using the Auth provided by App Service will allow you to use a social identity providers, and put a lot of the security burdens on the providers.
So, let’s click ok, and it’ll take just a moment or so to create the solution.
Okay, now that it’s done let’s look through the code and we’ll start with the Startup file.
This is a pretty lightweight file that will kick off the “ConfigureMobileApp” function, so let’s check that out. This lives under the App_Start folder.
Let’s go through what’s happening in the code. First we have an HttpConfiguration object, followed by setting up the MobileAppConfiguration. The “UseDefaultConfiguration” call here is an extension method provided in the “Microsoft.Azure.Mobile.Server.Quickstart” package. Calling this method is shorthand for several API calls, such as “AddMobileAppHomeController” and “AddTables.”
So UseDefaultConfiguration will add a home page, setup the API Controllers, map table controllers, and add push notifications.
Then to make sure the database tables are created, this template uses Entity Framework code first migrations.
This next section of code will handle setting up App Service Authentication, should you have it enabled in the portal.
Under the Startup class is some code for the Entity Framework migrations. EF is outside the scope of this course so I’m not going to focus on it. Though we should check out the controllers.
Let’s check out the values controller first, which is a standard Web API controller. The thing to take note of is this MobileAppController attribute, which registers the route, sets up the JSON serializer, and enables client version checking.
So if you already have Web APIs that you want to use for your mobile app backend, you can use the MobileAppController attribute. Using a Web API controller works, however you won’t get offline sync out of the box like you would with a TableController.
So let’s see how the TableController works by checking out the TodoItemController.
The TableController is an abstraction of the ApiController that provides some functionality for querying from the underlying table. Besides the CRUD functions TableControllers will enable offline sync, should you want to implement it.
So, this app is basically a Web API app. There’s a controller for the todo items that’s based on the TableController. Then in the Startup class the mobile app configuration takes place.
If you’re a .NET developer then most of this will be familiar to you. So, let’s deploy this with Web Deploy and test things out.
I’ve already signed in to my Azure account so all I need to do is select the existing mobile app and click ok. By selecting the existing mobile app it’ll automatically download the publishing profile.
Okay, notice this home page, this comes from the UseDefaultConfiguration. So it looks like everything deployed successfully. Let’s jump over to the mobile app to see if everything still works.
Here we are in the simulator, I’m going to type “.NET Backend”...and it looks like the seeded data from the database migration just pulled down.
If we head back into the portal and look at Easy Tables, notice it’s listed as an Unsupported service. Recall that Easy Tables only works with auto created Node.js backends.
So, when using .NET you need to manage the database table creation and schema changes manually. In our example EF was used behind the scenes to do all of that automatically.
Alright, let’s wrap up this lesson here. In our next lesson we’ll take a look at how to use App Service authentication.
About the Author
Ben Lambert is a software engineer and was previously the lead author for DevOps and Microsoft Azure training content at Cloud Academy. His courses and learning paths covered Cloud Ecosystem technologies such as DC/OS, configuration management tools, and containers. As a software engineer, Ben’s experience includes building highly available web and mobile apps. When he’s not building software, he’s hiking, camping, or creating video games.