Monday, May 30, 2011

GITCA's 24 hours in the cloud is coming

In case you missed the PDC 2010 Local (Bulgaria), where I showed how to build scalable video converter using Windows Azure Worker Role & Windows Azure Storage, or you would like to refresh your knowledge on Azure, please join the GITCA's 24 hours in the cloud event on June the 1st. My session is scheduled for 10:00 P.M. PDT (06:00 AM GMT, June the 2nd), but there are also a lot of good session which you might want to watch. During the event you can ask questions using the official twitter event hash: #24HitC . To join the event, simply visit this site on June the 1st: http://vepexp.microsoft.com/24HitC/ !

See you there!

Tuesday, April 19, 2011

Table Valued Parameter procedures with SQL Azure

Yes, it’s supported and it’s fairly easy to use a Table Value Parameter in stored procedures with SQL Azure. And here I will show you a quick introduction on how to do this.
In order to use a table value parameter in stored procedure we first need to create a custom user defined table type (UDT). Here is my very simple table UDT:
CREATE TYPE ReferenceIds AS TABLE
(
 Id INT
)

Now let’s create a stored procedure that accepts that type:

CREATE PROCEDURE [dbo].[upGetRefIds]
(
 @references ReferenceIds readonly
)
AS
BEGIN
 SELECT Count(Id) From @references
END

It is important to note that when using UDT as parameter, it can only be input parameter, and it must be explicitly set as read only.
Finally let’s write some ADO.NET:

            using (SqlConnection con =                          new SqlConnection(                             ConfigurationManager.                             ConnectionStrings["AzureSQL"].ConnectionString))             {
                 using (SqlCommand cmd = con.CreateCommand())                 {
                     cmd.CommandText = "upGetRefIds";
                     cmd.CommandType = CommandType.StoredProcedure;
                     DataTable dt = new DataTable();
                     dt.Columns.Add("Id", typeof(int));
                     dt.Rows.Add(2);
                     dt.Rows.Add(12);
                     dt.Rows.Add(2342);






                    con.Open();



                    cmd.Parameters.AddWithValue("@references", dt);
                     var result = cmd.ExecuteScalar();
                     System.Diagnostics.Debug.WriteLine(result.ToString());
                 }
             }

Maybe you already noted – the @references parameter is passed as regular DataTable, which has 1 column defined of type integer (same as our user defined type). This is the only “special” trick to make the magic work!

That’s it. As simple as that!

Saturday, April 2, 2011

Microsoft MVP for Windows Azure

Yes! It is not a April’s fool joke! It’s a fact! It is a great honor for me to be awarded with the Microsoft MVP Award for Windows Azure!

And of course, when there are awards and winners and prices, there are also “thanks”. My great thanks go for Martin Kulov (Microsoft Regional Director & Microsoft MVP for ALM) who is a great guy and incredible Microsoft influencer Smile! I am proud to know him! Of course also a huge gratitude to my family for supporting me in all mine initiatives!

So what’s next? Even more Windows Azure User Group meetings and even more community activities. Stay tuned for updates!

Slides and code from Microsoft Days’ 2011 Bulgaria / SQL Azure Agent

And here there are. PowerPoint presentation can be downloaded from: SqlAzureAgent_MSDays2011_20110330.pptx  And the code is located at: http://sqlazureagent.codeplex.com/. Go for it! Download, build, run, change, play! If you have questions: just ask!

Tuesday, March 29, 2011

Bug in CodePlex prevent publishing a release package

While I was completing my next CodePlex project, which will be published soon, I discovered a strange bug. There was some nasty JavaScript error which was preventing me from publishing a release. Initially I thought it is a specific browser issue, but I tried with every possible (not all of them, but major ones – FF, IE, GC, Opera) browser there is (for Windows) and the problem still was there. And now when I am really close to release I just wanted that release published.

At the end it appeared to be the DatePicker JS in the Release manager which was crashing under certain circumstances. That was preventing users from publishing a Release.
In order to reproduce the issue, set the "preferred languages" of your browser (any browser) to "Bulgarian, Bulgaria (bg-BG)" and remove all other languages. In that case the JavaScript correctly gets/sets the date format, which is "dd.mm.yyyy 'г.'", but that last 'г.' (which includes the single quotes) breaks the JavaScript for the page. Frankly I am not entirely sure whether the system locale settings also affect this behavior. All my machines are with system locale set to Bulgaria. However when I remove the "Bulgarian, Bulgaria (bg-BG)" from browser's preferred languages, and leave there only English everything works fine.

I reported this issue to the CodePlex team and hope that they will fix it soon Smile

Meanwhile, if you are e CodePlex enthusiast and have projects there, keep in mind that locale / language settings might affect your experience!