Azure Mobile Services For .Net Backend

Questions and Answers

Which tools and SDK version should I use for .Net Backend?

You should use the last stable version:

How to avoid  load of assemblies when the .Net project is updated

The Azure Mobile Services
 
The .Net Backend uses various Nuget packages and it is not recommended to update all Nuget available in the “Update” windows from “Manage Nuget Package”. We should only update the Microsoft Azure Mobile Services .Net Backend Entity Framework Extension Nuget package. If something went wrong you should uninstall all packages and then re-install.
 For more information see this article.
 
Which Nuget package should I use if I want to use Azure Storage? 
 
You can use the Microsoft Azure Mobile Services .NET Backend Azure Storage Extension, to avoid these kind of errors:
"Found conflicts among different versions of the same dependent assembly 'Microsoft.WindowsAzure.Storage': 4.3.0.0. Please change your project to use version '3.1.0.1' that is the one currently supported by the hosting environment."
 
Can I define Dev and Prod environments?

Yes, you can. To create different environments using the same code you can use transform the file as described in this article.

Can I run my services in localhost?

Yes, you can. In development you should use first localhost and after the tests are ok, you can publish it to the Azure. This way, you are not doing “call APIs” to your Azure Mobile Services. For more information see this article (Running the service in localhost).

Can I use a local SQL Server database when the services are running in localhost?

Yes, you can. In local development you can use a local SQL Server database but you must be aware that there are a few differences between a SQL Azure database and a SQL SQL Server database.

Can I use a SQL Azure database when the services are running in localhost?

Yes, you can. To use a SQL Azure database in localhost you must allow your IP to access the database and this configuration must be done in Azure Portal (in the database separator). For more information see this article (Defining the allowed IP for the database).

How I can see the WebConfig file published in Azure?

To see the WebConfig file published in Azure you should use Kudo. For more information see this article.

How to see the log files in the server?

In the Azure Portal, it is possible to see the logs from the selected Azure Mobile Service (in the Logs separator), but if for some reason it is necessary to see the log files, you should use Kudo to get it. For more information see this article and in this article (How to see details about errors).

How can I write my logs?

In your service, you should have a property called Services, provided for example by TableController that has a property called Log and this way it is possible to write logs and it is possible to define the type Error or Information.

Is it possible to debug my code running in Azure?

Yes, you can deploy to Azure and it is possible to debug that version, this way each request by the client application can be caught by the remote debugger. For more information see this article.

How should I manage images in Azure Mobile Services?

In Azure Mobile Services you should not send the image to the backend. You should not save in your SQL Database and you should save all images, videos and so on, in BLOB Storage. This way, you need notify the Backend about it and the Backend will provide the information required to upload the image to the BLOB storage. See more information in Upload images to Azure Storage using Mobile Services.

Why CreateAt, UpdateAt and Version are null in my requests?

These properties are called “system properties” and the client application can request it doing something as in the following:

  1. var q = todoTable.CreateQuery();  
  2. q.Parameters.Add("__systemproperties""*");  
  3. items = await q.Where(todoItem => todoItem.Complete == false).ToCollectionAsync(); 

Or using the solution provided in Using the new system properties of Azure Mobile Services Tables from a client application.

Should I use model and dtos or should I expose model as dtos?

It depends on the application requirements, but in general it is preferred to use a model and dtos because in some cases there is information in the database that cannot be public or shared outside, this way dtos only expose the information we need.

Tips
  1. To learn how to create a class diagram see this article.
  2. To define a router for a custom service in Azure Mobile Service it is the same as for an ASP.Net WebAPI and the following article describes it: How ASP.NET Web API routes HTTP requests to controllers and actions and Attribute Routing in ASP.NET Web API 2.
  3. To see the different configurations related to the Entity Framework Fluent API see the articles Configuring Relationships with the Fluent API, Configure One-to-Many Relationship, Configure Many-to-Many relationship and Code First Relationships Fluent API

Samples

Azure Mobile Services Samples
Samples to help developers to use Azure Mobile Services.

Microsoft Azure Mobile Service: How to create the Azure Mobile Service in Azure Portal.
The purpose of this article is to show how to create an Azure Mobile Service in the portal and how to create the Visual Studio 2013 Project.

Microsoft's Windows App Studio Beta: Connecting a Menu App to Azure Mobile Service.
The purpose of this article is to connect the Menu App from Windows App Studio with Azure Mobile Service, using .Net in the backend. It includes the main point each developer must understand:

  • Analysis the model
  • Create a table controller (a service)
  • Validate data
  • Overview about DomainManager class, EntityDomainManager<T> class
  • The Entity Framework's context
  • Database (connection string, defining the allowed IP for the database, migration, seed)
  • Running the service in localhost
  • Publish and run the service in Azure
  • How to see errors
  • Remote debug

Recommended Ebook

Azure Web Apps for Developers

Download Now!
Similar Articles