Skip to main content

Posts

Showing posts from July, 2012

Trace information to Windows Azure Azure Tables

I saw that there are a lot of people that use tracing infrastructure that is offered by .NET framework to trace information in Windows Azure Tables. Basically, after we configure the configuration file, the only thing that we need to do is to call the Trace class and write data to it. Trace.WriteLine(“Some trace data”); Trace.TraceWarning(“Some worning information”); Trace.TraceError(“An error that appeared in the application.”); We can do a log of thinks with this class. It is not something new. In the configuration file of our application we need to add a new trace listener that is able to write all the trace information to Azure Tables. <system.diagnostics> <trace> <listeners> <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics” name="DiagToAzureTables"></add> </listeners> </trace> </system.diagnostics> Next step is to add t

Windows Azure Websites - Shared and Reserved mode

I think that we all of us already heard about Windows Azure Websites. This new feature of Windows Azure offers us the possibility to deploy websites very fast. Even for the first deploy, the deploy time can be very low. What I would like to talk about today is the two different modes of Websites. The first one is Shared Website Mode. What does it means is that we don’t have a dedicated compute power. All the processor power is shared between our websites and other websites. From the performance perspective the performance will not be great. Is like hosting the websites to a classic hosting, that for 400$ per year host your application on IIS. The other mode is the Reserved one. For this case we have dedicated resources that are allocated only to our application. We don’t share processor, memory or anything else. For this case we have 3 types of sizes (Small, Medium, Large) that we can set. Also we can specify the numbers of reserved instances from 1 to 3. An interesting thing at Reser

How to use local configuration in a Metro App

Today I want to talk about where we can store application configuration in a Metro App for Windows 8. Basically, we don't have app.config file and because of this we need to "re-learn" how to store the application configuration. The entire configuration can be stored in the application storage under "LocalSettings". The default location where we can store and retrieve the configuration data is "Windows.Storage.ApplicationData.Current.LocalSettings". In the next example we add "MaxValue" to the LocalSettings and after that retrive it: Windows.Storage.ApplicationData.Current.LocalSettings.Values["MaxValue"] = 100; string maxValue = Windows.Storage.ApplicationData.Current.LocalSettings.Values["MaxValue"] = 100; Another thing that we can do with the LocaSettings is to create containers that can be used to group different settings. We can create unlimited number of containers with different settings. We cannot have two

Shared Access Signature and URL encoding on Windows Azure

Playing a little with Shared Access Signature was quite nice. In this moment this new functionality has a great potential. Playing a little with it I found an odd bug that I introduce from the code. From the start you need to know that this bug was generated by me and the cause of it was not Windows Azure. Normally after we generate the access signature we are adding it to the URL that we want to access and we get a code similar to this: var accessSignature = myTable.GetSharedAccessSignature(…); string accessURL = tableAccessURL + … + accessSignature; Uri accessUri = new Uri(accessURL); string myAccessLink = accessUri.ToString(); The only problem here is that the accessSignature can contains specials characters like ‘=’ or ‘+’. This kind of characters needs to be encoded in the URL. Because of this from time to time we will get an URL that is not valid. In my case last time I got an access signature that contained this kind of specials characters for 4 times in a row. Because of this

Accessing hardware configuration from a Metro App

When we create Metro Apps for Windows 8, we could imagine some scenario where we would like include some device resources information like CPU or memory usage. The bad news is that we cannot get this data from the device. And yes, Windows 8 works as expected. We need to realize that a Metro App run on Windows 8 in a very isolated environment. The application don’t need to know one what environment run, how many memory is used by the system and so on. The lifetime of the Metro App is controlled by the operating system and all the resources that an application can need are offered by the system. Remember? A Metro App should do only one think, but it should do this think best. In this moment I cannot imagine extreme Metro Apps, like some other desktop application that can do almost anything. If we realize that we work at a Metro App that do to many thinks, that a good idea is to split it in 3,4 or why not 10 applications. When we have a user that accesses our application, we don’t want to

Post event – CodeCamp Cluj-Napoca, July 2012

Yesterday, July 21, we had a new CodeCamp meeting in Cluj-Napoca. For almost 7 hours we talk about the new Windows Azure and how we can use Windows Azure features in Metro Style Applications for Windows 8, software architecture and responsive web design. Even if it was a perfect summer day, around 45 persons came to this event. Special thanks to our sponsors: ISDC and Pentalog and congratulation all. At this event I talked about how we create smart Metro Style Application for Windows 8 using Windows Azure. You can find my presentations here: How to use windows azure features on windows from Radu Vunvulea I will add to this post link to the rest of the presentations next week: Windows Azure just got REALLY serious, Mihai Nadăș Azure WebSites – more than shared hosting, Mihai Tătăran How to use Windows Azure features on Windows 8 , Radu Vunvulea Architecture in theory and practice , Cristian Odea, Sergiu Damian Responsive Web Design, Lorant Domokos In the end I

SQL - UNION and UNION ALL

I think that all of us used until now UNION in a SQLstatement. Using this operator we can combine the result of 2 queries. For example we want to display the name of all our clients.In our database the clients are stored in separate databases based on theregion. To be able to display the name of all our clients we need to execute aquery on different table and combine the result: SELECT Name FROM EuropeClients UNION SELECT Name FROM AsiaClients Each time when we execute this call everything is fine. Inone day, the marketing team observes that there are clients that appear inEurope, but also in Asia, but when we execute this query we don’t have anyduplicated data. This happen because UNION removes any duplicates rows.Because of this, if we want to count how many time a client name appears, itwill not be possible using just UNION. SELECT Name, count(*) AS Count FROM (SELECT Name FROM EuropeClients UNION SELECT Name FROM AsiaClients) GROUP BY Name For this query, the Count column will be 1

Some scenarios when we can use Shared Access Signature from Windows Azure

In this post we will talk about some possible scenario when Shared Access Policy can be used. We will discuss about a different scenario for blobs, tables and queues. Blobs We are a graphical designer that creates templates for web applications. We decide that we what to offer this content to any persons based on a subscription that is paid for each template package. A template package can contain 100 web applications template for example. How we can share this content very easily with our clients. A simple solution is using blobs and Shared Access Signature. For each client we create an access token that allow to access the templates for which he paid. Over this structure we create a web-application that allow user to download the templates packages after he insert his access token that is send via email. Table Let’s imagine an application that store on Azure table information about stock reports for the each weeks. This information is generated based on a lot of compu

Shared Access Signature on Windows Azure - Overview

Until now we saw how we can work with Shared Access Signature on blobs , tables and queues on Windows Azure. In this post we will try to see how this mechanism works in more details. The Shared Access Signature can be used from any language. Until now I have example only from C#, where we used the current API to make calls to generate and set the access policy. This is not the only way to generate and configure them. All this features are exposed on Windows Azure as a RES API that can be used very easily. There are different ways to make the REST API calls; we can send the configuration items in the query string or in the body of the request. The most important think that we need to know is that each access policy that is created need to have a unique id (string) and a list of permissions. Each type of resources supports different permissions types: Read – r Add – a Update – u Delete - d Process – p List - l For each resource that is used we need to define the permissions in

A strange way to make an update to items from database

Last week I heard an interesting discussions between a tester and a developer. The tester was upset that he discovered the following flow on an update action of an item from database: Client: request and get an item from server Client: change some data from the item Client: send an update command to the server Server: get the update command request Server: delete from database the given item Server: recreate the item as a new item with the updated data What do you see wrong in this flow? (I hope that you spotted the problem already) For each update, the server deletes the item from database and recreates the item. Each deleted item is marked only as deleted in database but is not physical removed, because we need a tracking mechanism. This is a very bad practice. We are talking about a small web-application that recreates each item when the user changes some fields on it. Imagine the following scenario: The web application is an e-commerce solution and has around 10.000 ite

How to remove or edit a Shared Access Signature from Windows Azure

Until now we saw how we can create a Shared Access Signature for blobs , table and queues . In real life scenario, this is not all the think that we do. After we create a Shared Access Signature we want to be able to edit or remove it. In this blog post we will look over some common scenario that can appear when we work with Shared Access Signature. The first scenario is when we want to remove the access to a resources using Shared Access Signature. After we created an access signature and we shared with the client, maybe we realize that we send the access signature to the wrong user for example. For this case we want to delete the access signature from the permissions list. For this cased is very important to have stored (or to be able to recreate) the name of permissions that we created. If you remember, when we create an access policy we set a unique name for each policy. Based on this name we can remove any access policy that we created. Blobs, tables and queues have a method na

How to use Shared Access Signature with tables from Windows Azure

Until now we talk about how to use Shared Access Signature on blobs and queues from Windows Azure. Today we will see how we can use Shared Access Signature with tables from Windows Azure. Using this feature we can give a limited access to a consumer to Windows Azure tables. In the next part we will look over what are the restrictions that can be made using Shared Access Signature: The first limitation that we can add is the time range. Based on the time a user can have a limited access to a table. For example a user can have access to a table only from 1st of July until the end of the week. We can limit what actions can be done using a Shared Access Signature. The following actions can be specified: add, update, delete and query. We can give access to a table or to only a part of a table. This limitation can be done using the partition key and row key. For example we can limit a consumer to have access only to partions keys from pkStart to pkEnd and from row rwStart to rwEnd. The