Azure Mobile Services For .Net Backend
Questions and Answers
You should use the last stable version:
- Visual Studio 2013 Update 4
- Azure SDK 2.5
- Last stable Nuget packages
How to avoid load of assemblies when the .Net project is updated
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 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:
var q = todoTable.CreateQuery();
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.
- To learn how to create a class diagram see this article.
- 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.
- 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
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