Skip to main content

Posts

Showing posts from 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 Wh...

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...

Mobile Service on Windows Azure (part 3)

Presentation 2   Yesterday I had the last session about Mobile Services on Windows Azure for MSP of UTCN from Cluj-Napoca. We talk about authentication and push notification on mobile devices as Windows 8, Windows Phone 8. Mobile Services from Windows Azure can save as not only from a lot of work but also can reduce our application complexity. Don’t forget that authentication using Mobile Services will not provide you access to SkyDrive or other services that are coming with a Windows Live account. Here is my presentation:

Windows 8 Dev Camp Sibiu, 24.11.2012 - Postevent

This Saturday we had our first CodeCamp event in Sibiu . Even if it was the first event in Sibiu we had a lot of attenders – we were almost 100 people that stayed with us almost 7 hours. This event was dedicated to Windows 8 and was named “Windows 8 Dev Camp”. We tacked a lot about Windows 8 from different perspective and how can be integrated with different services like Mobile Services or Media Services from Windows Azure. Because this event was an event dedicated to developers and technical persons we tried to explain all the base thing that a develop need to know about Windows 8. One of our speakers (Mihai Tataran), brought in exclusivity a Windows Surface. This is a great device with a high potential. All the people that stayed until the end had the chance to win some software licenses. At this event I talked about the architecture of Windows 8, WinRT, native languages that are available on this new platform and what thing that a developer need to know. You can find my presenta...

Mobile Services from Windows Azure - Introduction

What do you think about Windows 8 and Windows Store? It has a great potential and is a place where people with good ideas can develop application. Usually when you develop an application you also need a backend. A place where authenticate users, to store data and so on. Windows Azure comes with a solution that can freaks out any kind of backend developer – Mobile Services Why is so great? A lot of backend stuff that you need in a normal mobile application is built in. Let me give you some example: Authentication infrastructure for Windows Live, FB, Twitter, Google and more coming soon Push notification Store data on the server Custom scripts on working with server data And this is not all. Imagine that you develop an application for iOS. Could you integrate Mobile Services from Windows Azure? YES, you can. In this moment, after you setup your mobile service you can download a sample application for Windows 8 App, Windows Phone or iOS that contains all the settings for your acc...

NetCamp 2012 - Windows 8 development experience

During this week I participate to NetCamp 2012.  This was the 6th NetCamp event and is organizing by Evensys. NetCamp is a dedicated event for online entrepreneur and how they can turn their ideas in reality. What I’m doing there? Well, I had a session where I presented how was the development process of Trip Journal on Windows 8 and what are the things that an entrepreneur should take into account when select the platform for their application. Any entrepreneur that would like to develop mobile application in Windows 8 should take into account the following thinks (these are the most important ideas from my presentation): Windows Store – a big opportunity for any person with ideas. It is place where your application can be visible to users Windows 8 Apps – one application for desktop and tablet version. You don’t need to write different applications for different devices 3 native languages that can be used to develop a Windows 8 App – C#, C++, JavaScript Windows Store App i...

CDN is not the only solution to improve the page speed - Reverse Caching Proxy

I heard more and more often think like this: “If your website is to slow, you should use a CDN.” Great, CDN is THE solution for any kind of problems… or not. Depends what is our problem. First of all let’s see what does CDN means. Content Delivery Network gives us the possibility to improve our web application performance by distributing our content in different geographical location that is closed to our client. This is a great solution when we have static content like images, videos or any kind of static content. In this moment there are a lot of great solutions, from Azure CDN that are very easy to config and scalable to EdgeCast or Akamai. But maybe our problem is not from there. What happens if users are in the same geographical region? Using a CDN may or not may improve our speed performance. The entire request will hit our servers. A bunny will tell us: “It’s not a problem dude, we live in the cloud nowadays, scale up your application on more instances”. HTTP Caching Reverse...

Windows Azure Tables - One of the request inputs is not valid.

In this blog post we will talk about an error that occurs when we want to delete or update entities from Windows Azure Tables. Let’s assume that we have the following code: TableServiceContext serviceContext; … serviceContext.AttachTo(“MyFooTable”,entity); serviceContext.DeleteObject(entity); serviceContext.SaveChanges(); When we run the code we will see the following error message: One of the request inputs is not valid. The source of the problem is the ETag. ETag is used to track changes of an entity and commands like delete use this ETag to check if the entity that is deleted is the last version of entity. If we are share that we want to delete this entity we can set the 3th parameter of AttachTo to “*”. Using “*”, you will specify to the context to not track the entity based on the ETag. Our code should look something like this: TableServiceContext serviceContext; … serviceContext.AttachTo(“MyFooTable”,entity, “*”); serviceContext.DeleteObject(entity); serviceContext.SaveChan...

Why and Where for MongoDB, Cassandra, CouchDB, HBase, Membase, Redis

More and more people are starting to use NoSQL. I think this is extremely good. NoSQL can make our life better in a lot of situations. In this post I will try make a list of current NoSQL solutions that exist on the market and when we should use each other. MongoDB Why Dynamic query Content is stored as documents Big database that need to be very fast Where Properties are stored like query and index Can be used for voting system, CMS or comment storage Cassandra Why When you make a lot of updates and insert Reading data is not the main scope of the database (writes are faster than reads) Content is stored as column High availability Where Can be used with success for logging Financial industry or any place where we work with a lot of data that is needed to be written Basket of an e-commerce application CouchDB Why For data that don’t change very often (insert and read and NOT update) We have a lot of predefined queries and we need versioning support ...

Service Bus Topic - Automatic forward messages from a subscription to a topic

Windows Azure Service Bus Topic is a service that enables us to distribute the same messages to different consumers without having to know each consumer. The only think that we need to do is to know the topic name. Each consumer will need to create and connect to a different subscription. Each message added to topic will be forward to each subscription. There are times when we need to forward a message from a subscription to another topic or queue. Until now we had to use a worker role that took the message from the subscription and adding it to the second topic. From now, a subscription supports this great functionality, by default. We only need to set the name of the topic or queue of the Service Bus where we want to forward the message. SubscriptionDescription description = new SubscriptionDescription("topic1","subscription1"); description.ForwardTo = "topic2"; SqlFilter filter = new SqlFilter("FW = true"); namespaceManager.CreateSubscripti...

WOWZAPP2012 - Awesome Hackathon

 This weekend, all around the word we had WOWZAPP Hackathon .  This Windows 8 Hackathon was a 48 marathon of Windows 8 App development. Over 15.000 people were connected with Visual Studio 2012 and develop great application for the new operating system – Windows 8. I participate at this event with other 3 colleges and we develop an application that could help you to find location when you don’t have internet connection. We didn’t manage to finish it, we tried to apply MVVM pattern 100%. Our main focus was the code quality and not to finish in 48h. The team name was DOTNET Vampires and team member were: Costin Morariu, Iulia Gorcea, Alexandra Vunvulea and @me. This was a great event and we had a lot of fun. In Bucharest, we had almost 40 team. At this event I was not only as a percipient, I was part of the Windows 8 SWAT team. We were the persons that offered technical support for all teams. I think that almost all project had at least 3 lines of code written by me. It was ...

Windows 8 Dev Camp in Sibiu - 24 nov 2012

After the Windows 8 Dev Camp from Cluj-Napoca, we are preparing Windows 8 Dev Camp in Sibiu. To be able to register please follow this link: http://codecamp-sibiu-nov2012.eventbrite.com/   Here is the announcement message for Romanian guys: ÃŽn urmă cu aproape o luna, Microsoft a lansat un nou sistem de operare - Windows 8. Cu această ocazie Codecamp împreună cu ITSpark vă invită la “Windows 8 Dev Camp ”. ÃŽn cadrul acestui eveniment o să disecăm o parte din secretele pe care un dezvoltator trebuie să le cunoască despre Windows 8. Participarea la eveniment este gratuită . MulÈ›umim în special iQuest pentru susÈ›inere. Agendă 9:15-09:30 Sosirea participanÈ›ilor 09:30-10:20 What's new in Windows 8? Tudor Damian A brief overview of the new features and performance improvements in Windows 8. 10:30-11:20 Developing modern web applications: HTML 5, MVVM, Web Sockets Mihai Tătăran In this session you will see a modern approach to web application...

Caliburn.Micro + Windows 8 App - How to send parameter between ViewModel's

What do you think about the development process in a C#/XAML app for Windows 8. When we are starting developing an application for this platform we should never forget about MVVM. A great framework for this is Caliburn.Micro. It is a pretty simple and clean framework, with a lot of extensions points. When we will try to navigate between screens we will use INavigationService.NavigateToViewModel<TDestionViewModel>. This will work great. Navigation.NavigateToViewModel<MyFooPageViewModel>(); Each ViewModel need to implement the Screen class. This will give access to all the features that we need in the view mode. But what about sending data from one view to another. The method NavigateToViewModel can accept an parameter of type object. Navigation.NavigateToViewModel<MyFooPageViewModel>(“some data”); Looks good but you will be surprised when you will try to get this data in your destination ViewModel. You will not be able to find this data anywhere. To be able to ac...

How to fix "Could not load file or assembly 'msshrtmi.dll' ... when you are using .NET 4.5 and Windows Azure 1.8 SDK

vIf you started to work with Windows Azure SDK 1.8 on a .NET 4.5 projects, maybe you received the following error message: The type initializer for 'Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment' threw an exception. … {"Could not load file or assembly 'msshrtmi.dll' or one of its dependencies. A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A)":"msshrtmi.dll"} This problem usually appears in a console or desktop application when you are trying to use storage service from Windows Azure (blobs, tables or queues). The solution is pretty simple, but can give you a lot of headaches until you find what the problem is. The code is okay; you didn’t make any kind of mistake. You only need to change some configurations from app.config. You will need to add “useLegacyV2RuntimeActivationPolicy” attribute to the startup node and set it to true. This flat notifies the .NET framework that you have dependenci...

Today Software Magazine number 6 - Message Patterns using Windows Azure Service Bus

This week, Today Software Magazine lunched a new number of their magazine. Great article about software development can be found in this paper. Great articles about SEO, to clean code and cloud can be found in this number. I wrote an article about message patterns and Windows Azure Service Bus Topic. In this article I presented two cases when message patterns in combination with Windows Azure Service Bus Topic can make our life easier and to be more prepared for change. The current number can be downloading from the following link: http://www.todaysoftmag.com/pdf/TSM_6_2012_ro.pdf  At the lunch event I made a short presentation of my article. I added to this blog post my slides: Message pattern in windows azure service bus from Radu Vunvulea

How to start Windows Azure emulator when running unit tests

Unit test need to be written even if we are working with on-premise services or with services from cloud. When working with Windows Azure, there are times when we want to write some integration test for Windows Azure tables, blobs or queues. For these cases we don’t want to hit the Windows Azure from the cloud. This would increase or monthly subscription costs. Usually for this this Windows Storage emulator is used in combination with development storage account. When we are on a development machine, where we already have Windows Azure Emulator stared we will not have any kind of problems. But will happen on a machine where Windows Azure Emulator is not started. All the tests will fail. We can write a code in the class initialize step that star the emulator. In the end, the emulator is only a process that can be started from the command line. The code that we would need to use will look something like this: public class CloudStorageEmulatorShepherd { public void...

How to view Skype messages older than 3 months

This blog post will not be about programing. In this morning, while I was playing with my Windows Phone 7 I run our off battery. Of course the phone closed. The only problem was the PIN, I don’t remember my SIM pin (this is the first time in 7 months when I closed the phone). I knew that I have the SIM pin in my Skype history, but the message is older than 3 months, because of this I could not access the history from that period of time. The good part with Skype is even if is not displaying all the history, he still persist the older messages. All the messages can be found in the “%appdata%\skype” in the directory with your Skype user. The easiest way to go at this location is to open a command line and write “%appdata%\skype”. The file that stores all this content is main.db. Don’t worry about how you can open this file of is encrypted. It is a simple SQLite file. Is not encrypted and can be pen very easily. A good tool for this purpose is Skype Log View . He will automatically open t...

Free online event about Windows Azure - November 14, 2012

If you work with Windows Azure and you want to learn more about this great cloud ecosystem or you want to know what can be done on Windows Azure and what are the main features than… Microsoft will host Windows AzureConf, a free online event that is done for Windows Azure community. You will be able to see a lot of sessions about Windows Azure. This will be streamed live using Channel 9. When:  November 14, 2012 When: all over the world - live stream If you want to register or read more about this event follow this link .

Duplicate Detection in Windows Azure Service Bus

One great feature of Windows Azure Service Bus is the ability to identify the messages that are duplicate. Using this feature we can automatically remove messages from Service Bus Queue or Topic when we have more than one the same message. By default this mechanism is deactivated, but we can activate it very easily. Let’s see how this mechanism works. When we activate this mechanism Windows Azure Service Bus will start to store a history with our messages. This period of time can be configures from only a few minutes to days. If a duplicate message is send to Service Bus, the service will automatically ignore the message. Because the content of each message need to be serializable, the duplicate detection mechanism will look to the serialized items that were added to the message. If the content is the same, than the message will be consider as duplicate. For example we have the following class that we add to each message: [DataContract] public Foo { [DataMember] public strin...

Windows Azure Tools - Error 0x80070643: Failed to install MSI package

Today I had to install Visual Studio 2012 and Windows Azure 1.8 SDK for a new project. Everything went as a charm; I didn’t have any kind of problems. But after a while I realized that I had a project that is written in .NET 4.0 and use Windows Azure 1.6 SDK and an update to 1.8 is in this moment is not possible. After installing Visual Studio 2012 and Windows Azure 1.8 SDK I tried to run my old project, but without success. In that moment I realize that I have a big problem, because I will not be able to provide support for that project. I uninstall Windows Azure 1.8 SDK, installed 1.6 but without success. I tried to uninstall Visual Studio 2012 with success. After that I accessed Windows Azure web site and download Windows Azure 1.6 SDK and Windows Azure Tools 1.6 but I received an error when I tried to install Windows Azure Tools 1.6. Error 0x80070643: Failed to install MSI package I tried to repair Visual Studio 2010, uninstall and reinstall all the kits related to Windows Azure...

Visual Studio - How to see the source code of .NET framework

Every time when I’m installing Visual Studio one a clean computer I have problems remembering the steps that need to be done on Visual Studio to see the source code of the .NET framework. In the next lines we will look over the steps that need to be done. Next time when I will need to make this configuration I will come back to this post. We need to go in Visual Studio menu, under Tool->Options and select the Debugging tab. In the general node we will need to check/uncheck the following options: Uncheck the “Enable Just My Code (Managed only)” Uncheck “Require source files to exactly math the original version” Check “Enable source server support” In this moment we are almost done, the only think that we need to do is to double check under Symbols node that “All modules, unless excluded” is checked. In general I prefer to create a custom path where the symbols are downloaded. While you are debugging, if you have any kind of problems loading this symbols, go on the...