Skip to main content


Showing posts from December, 2012

Today Software Magazine, 7th number - Writing about Windows Azure Mobile Services

Yesterday, December 17th, the 7th number of Today Software Magazine was lunched. In this number I wrote an article about how a backend of a mobile application should look like. To be able to create a backend for a mobile application I presented Windows Azure Mobile Services. Windows Azure Mobile Services come with a mechanism build in to store data, authenticate users, push data to devices and define custom scripts on the server side. There are two things that are very interesting: Build in support for iOS and Android, not only for application developed for Windows Store and Windows Phone JavaScript used for define server side script You can find the article here .

Mobile Services from Windows Azure - Data Store and custom script(part 3)

Part 2 In last post we saw how we can create a table using Mobile Services to store GPS position. We discover how we can setup who can make each CRUD operation on our table. In this post we will continue to see how we can write data and retrieves data from our table. We already created an instance of MobileServiceClient. From this service we will need to retrieve an instance to our table using GetTable method. After we have a reference to our table (IMobileServiceTable) we will be able to execute any kind of request over our table: IMobileServiceTable tableService = mobileServiceClient.GetTable<Location>(); await tableService.InsertAsync(location); await tableService.Select(l=> { … }); await tableService.UpdateAsync(location); I think that you already notified that all the methods are async. Also, you don’t need to manual create a new instance of the IMobileServiceTable. This is handled by the Mobile Services component automatically. Do you remember how we setup our tabl

Code, code and code

In this post I will talk about 5 bad things that I saw in different projects. A part of them is common sense, but people forget about this. Base class name convention XXXBase class is defined and used as a base class. Until this point this is perfect, but what do you think about this: public class XXXBase { … } Why you defined a base class that you want to be used as a base class for other class without the abstract keyword. If you want a base class doesn’t forget to add the ‘abstract’ keyword. You can use the naming conventions but this will not stop people to create instances of your base clas.. Method named like the class If you have a class named XXX, don’t define a method in your class named StartXXX, ConvertXXX. When a user uses an instance of XXX he will already know that he do the actions over XXX. Examples: Converter.StartConvert() – Converter.Start() Service.StartService() – Service.Start() Engine.StartEngine – Engine.Start()   TODO comments and production What d

Mobile Services from Windows Azure - Data Store (part 2)

Part 1 When we need a backed to store data for a mobile application Windows Azure Mobile Services can be a great solution. Let’s imagine that we need to develop a mobile application that need to store the GPS location of our client. For this purpose we can develop a complicated solution, with a backed that exposes this functionality as services. Also we will need an authentication mechanism that will add another layer of complexity. All this functionalities are already supported by Windows Azure Mobile Services. In this blog post we will see how we can configure. First step is to configure our Windows Azure account to have Mobile Services active. In this moment Mobile Services is in the preview, because of this before creating a Mobile Services you will need to sign up to this preview. From the new command of the portal you will find a link to the sign up page for the preview. The activation time period is very short. Each Mobile Services has a unique name, which will identify our

Windows Azure Table - How to chunk commands in batches of 100 items

Based on what kind of data store we are using, there are cases when the size of a batch is limited. For example if we want to execute an update batch command over Windows Azure Tables we will notify that the maxim size of a batch is 100. Also all the updated command needs to be on the same partition key. What should we do if we have a batch that with more than 100 items. The simples’ solution is to create groups of chunks of 100 items and execute and execute them in parallel. In the next part of the post we will see how we can create chunks of items from a list: List<Foo> items = new List<Foo>(); …. int chunkSize = 100; List<List<Foo>> chunks = new List<List<Foo>>(); int index = 0; int itemsCount = items.Count; while( index < itemsCount ) { int count = itemsCount > chunkSize ? itemsCount : index; Chunks.Add( items.GetRange( index, count)); } After this step if we need to execute the update command over the table context we ca

How we can remove millions of entities from a Windows Azure Table (part 2)

In one of my latest post I tacked about how we can remove a lot of entities from Windows Azure – deleting the table. This solution works but we will have to face up with an odd problem. When we are deleting a table, we only mark it for deletion, our client will not be able to access the table and in background Windows Azure will start deleting the table. If we have a table with millions of entities will face up with a big problem. Until Windows Azure will finish deletion of the table will not be able to create a new table with the same time. This can be a blocker. We don’t want to wait 4 hours, until our table is deleted to be able to recreate another one. And here is a big BUT. We can be smart and use ListTables. Basically we can create another table that have the name something like [MyTableName]+[Guid] and using ListTable method to retrieve the name of our table only using [MyTableName]. Using this solution, we can add mark our old table for delegation and create a new table w

How we can remove millions of entities from a Windows Azure Table (part 1)

Part 2 Windows Azure Table is a great please to persist different information. We can store in the same table thousands of thousands of thousands of thousands of items. This sounds so good, but we can have small problems. The first problem that we can face up is how we can delete all the content of a table very fast. The maximum number of items that we can update/delete in a batch is 100 entities. Because of this deleting 1 million of entities will take a long of time. We could try to parallelize this action, but this is a little complicated and maybe we don’t want to do this. Another solution that we could use is to delete this table and recreate it. If you need to drop all the content from a table this is faster than delete entity by entity. Think in this way. When you need to remove the content of the text file, it is faster to delete row by row or to delete the file and recreate it. CloudTableClient tableStorage = new CloudTableClient( [absoluteUri], [credentials]); table

Windows Azure Service Bus Topic - Detect messages that don't have subscribers

Windows Azure Service Bus Topic is a great service that provide as the ability to distribute a message to more than one subscriber. When we publish a message to Service Bus Topic we don’t need to know how many subscribers are. Each subscriber can register to a topic and receive the messages (each subscriber can define custom rules – to filter what kind of message he wants to receive). But how can we check if a message will be received by at least one subscriber. When we publish a message we don’t know who will receive the message, because of this we need a way to know what messages were not received by anyone. In this current implementation of Service Bus Topic, when a message is send to the Service Bus Topic and the current messages is not accepted by any subscriber, the message is not persisted in the Topic. Because of this the message will be lost and we will not be notifies about this action. Service Bus Topic give us the ability to be notifies when we send a message to the Servi