The Elements of Distributed Architecture (Clemens Vasters) – I just watch few minutes, but it look great! Introduction to the key elements of distributed software architecture. [video]
Moving My Data To The Cloud - In this nice post the author explain how he moved all is different data (photos, data, music, games, etc.) to different cloud solution.
Four Questions With … Clemens Vasters (seroter)- Interesting topics in this interview with one of the public face of Azure team about different topic.
MVC on Azure for Beginner (Henry He) - Definitively a good starting point for everyone want to start or try Azure and Asp.Net MVC.
Introducing Microsoft Sync Framework - A good product that is the core of the new Azure Data Sync. If you want a better configuration capability you will need sync framework.
How to avoid chaos in the cloud - We are at a time were the cloud is only beginning and nobody know how it will grow... this post ask so questions about the near future
New SQL Azure lab available (How to move data to SQL Azure) (Susan Ibach) - Microsoft Codename “Data Transfer” Tutorial (Liam Cavanagh - MSFT)- Nice tools quick and simple. However I got some hard time trying it, my Excel or csv file was not process. Finally I discover that the problem was my column name. Don't use ID as name for a column. Use something less generic like CustomerID... and it will work just fine.
I was re-doing some of the labs in the Windows Azure Platform Training Kit (WAPTK) when one of then didn't works: MessagingWithQueue. A got this error message:
Could not connect to net.tcp://xxxx.servicebus.windows.net:9354/.
The connection attempt lasted for a time span of 00:00:00.0615234.
TCP error code 10061: No connection could be made because the target machine actively refused it.
Quickly this message is saying that the port 9354 need to be open. So I was going to ask to open this port, but then I ask my self: “What if I couldn't?” Does Azure service Bus suppose to be super flexible and give me the opportunity to you all kind of connection? Of course it does, so I decide to make a RESTful version of this lab.
Let’s begin
Create a new Cloud project in Visual Studio, and add a web role. In fact, regular web project will work just fine, but to keep it close to the original lab I will start with a cloud on. In the content folder add preloader.gif and override the Site.css (all the code, images and files are available here). In the View / Shared folder override the Site.Master and in View / Home override Index.aspx. You can run now the application, you should see something like that:
Create Azure AppFabric Service Bus
On the Azure management portal at windows.azure.com In the Service Bus section, create a new Service Bus. You will need the Service Gateway, the Default Issuer (always “owner” in the CTP) and the Default Key.
Create New Queues
To Create a queue the button “Create” in section B will send the text, the queue name, to the Home controller and let us know the result. To do that let’s add some JavaScript /JQuery code in the Index page.
var getQueuesUrl = '< %= Url.Action("Queues") % >';
$(document).ready(function () {
loadQueues();
$("#createQueue").submit(function (event) {
event.preventDefault();
var url = $(this).attr('action');
var queueName = $("#queueName").val();
$(".loading").show();
$("#send").attr("disabled", "true");
$("#retrieve").attr("disabled", "true");
$.post(url, { queueName: queueName })
.success(function (response) { renderCreateQueueStatus(response); })
.error(function () { renderCreateQueueStatus(false); });
});
});
function renderCreateQueueStatus(response) {
if (response) {
$("#createQueueStatus").html("Queue created successfully!");
loadQueues();
} else {
$("#createQueueStatus").html("An error occurred, please try again later.");
}
$(".loading").hide();
$("#send").attr("disabled", "");
$("#retrieve").attr("disabled", "");
}
function loadQueues() {
$.get(getQueuesUrl).success(function (response) {
var ul = $("fieldset.center > ul");
var sendMsgCombo = $("#sendMessageQueue");
var receiveMsgCombo = $("#retrieveMessageQueue");
sendMsgCombo.children().remove();
receiveMsgCombo.children().remove();
ul.children().remove();
for (var i = 0; i < response.length; i++) {
var item = response[i];
sendMsgCombo.append('<option value="' + item.Name + '">' + item.Name + '</option>');
receiveMsgCombo.append('<option value="' + item.Name + '">' + item.Name + '</option>');
ul.append('<li><label>' + item.Name + '</label><div class="msgCountOf' + item.Name.replace(/ /g, '') + '" style="float:right"><label>Messages</label></div></li>');
updateMessageCountOf(item.Name, item.Messages);
}
});
$(".loading").hide();
}
function updateMessageCountOf(queueName, numberOfMessages) {
var message = numberOfMessages + " Messages";
if (numberOfMessages == "0") message = "No Messages";
if (numberOfMessages == "1") message = numberOfMessages + " Message";
$("div.msgCountOf" + queueName.replace(/ /g, '') + " > label").html(message);
}
Once the document is ready loadQueues() is called. This function will loop through a list of queues name and fill the two listbox and the build the middle list .
Using Jquery the $("#createQueue") add a submit function to the button with the ID createQueue and on the success or error will call the function renderCreateQueueStatus to update the content of the Label createQueueStatus. Then recall loadQueues() so it can refresh the queues lists.
On the server side now we will need a function CreateQueue that accept a string parameter as queue name and return a JsonResult. This function should act as a HttpPost. To communicate a token is needed. This is done by the primary call to Index. It’s creating a token for us with the issuer name and issuer secret of our Service bus with the function GetToken.
Put the information about your Service Bus (Service Gateway, Issuer and Key) in the Settings.The default constructor load this information.
To update the list of our queues we will use a function Queues(). This will download the information from “$Resources/Queues” and build a array of Json object with properties: Name and Messages. It took me some time before this Linq query works, the tricks is to use the namespace when looking for a node.
public class HomeController : Controller
{
private String mServiceNamespace;
private static String mBaseAddress;
private static String mToken;
private String mIssuerName;
private String mIssuerSecret;
private const String SBHOSTNAME = "servicebus.windows.net";
private const String ACSHOSTNAME = "accesscontrol.windows.net";
private const String ATOMNS = "{http://www.w3.org/2005/Atom}";
private const String SBNS = "{http://schemas.microsoft.com/netservices/2010/10/servicebus/connect}";
public HomeController()
{
mServiceNamespace = RoleEnvironment.GetConfigurationSettingValue("namespaceAddress");
mIssuerName = RoleEnvironment.GetConfigurationSettingValue("issuerName");
mIssuerSecret = RoleEnvironment.GetConfigurationSettingValue("issuerSecret");
mBaseAddress = "https://" + mServiceNamespace + "." + SBHOSTNAME + "/";
}
public ActionResult Index()
{
try
{
// Get a SWT token from the Access Control Service, given the issuerName and issuerSecret values.
mToken = GetToken(mIssuerName, mIssuerSecret);
}
catch (WebException we)
{
using (HttpWebResponse response = we.Response as HttpWebResponse)
{
if (response != null)
{
ViewBag.Message += Environment.NewLine + (new StreamReader(response.GetResponseStream()).ReadToEnd());
}
else
{
ViewBag.Message += Environment.NewLine + (we.ToString());
}
}
}
return View();
}
[HttpPost]
public JsonResult CreateQueue(String queueName)
{
try
{
var _queueAddress = mBaseAddress + queueName;
var _webClient = GetWebClient();
var _putData = @"<entry xmlns=""http://www.w3.org/2005/Atom"">
<title type=""text"">" + queueName + @"</title>
<content type=""application/xml"">
<QueueDescription xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"" />
</content>
</entry>";
byte[] _response = _webClient.UploadData(_queueAddress, "PUT", Encoding.UTF8.GetBytes(_putData));
var _queueDescription = Encoding.UTF8.GetString(_response);
return Json(_queueDescription, JsonRequestBehavior.AllowGet);
}
catch
{
return Json(false, JsonRequestBehavior.AllowGet);
}
}
[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
public JsonResult Queues()
{
var _xDoc = XDocument.Parse(GetResources("$Resources/Queues"));
var _queues = (from entry in _xDoc.Descendants(ATOMNS + "entry")
select new
{
Name = entry.Element(ATOMNS + "title").Value,
Messages = entry.Element(ATOMNS + "content").Element(SBNS + "QueueDescription").Element(SBNS + "MessageCount").Value
}).ToArray();
return Json(_queues, JsonRequestBehavior.AllowGet);
}
private WebClient GetWebClient()
{
var _webClient = new WebClient();
_webClient.Headers[HttpRequestHeader.Authorization] = mToken;
return _webClient;
}
private String GetToken(String issuerName, String issuerSecret)
{
var acsEndpoint = "https://" + mServiceNamespace + "-sb." + ACSHOSTNAME + "/WRAPv0.9/";
var realm = "http://" + mServiceNamespace + "." + SBHOSTNAME + "/";
var _values = new NameValueCollection();
_values.Add("wrap_name", issuerName);
_values.Add("wrap_password", issuerSecret);
_values.Add("wrap_scope", realm);
var _webClient = new WebClient();
byte[] response = _webClient.UploadValues(acsEndpoint, _values);
var _responseString = Encoding.UTF8.GetString(response);
var _responseProperties = _responseString.Split('&');
var _tokenProperty = _responseProperties[0].Split('=');
var _token = Uri.UnescapeDataString(_tokenProperty[1]);
return "WRAP access_token=\"" + _token + "\"";
}
private String GetResources(String resourceAddress)
{
String _fullAddress = mBaseAddress + resourceAddress;
var _webClient = GetWebClient();
return _webClient.DownloadString(_fullAddress); ;
}
}
Send a Message
On the client side using JQuery we add a submit event that will call SendMessage from our controller then update the status and the message count.
$(document).ready(function () {
$("#sendMessage").submit(function (event) {
event.preventDefault();
var url = $(this).attr('action');
var queueName = $("#sendMessageQueue option:selected").val();
var message = $("#messageToSend").val();
$(".loading").show();
$("#create").attr("disabled", "true");
$("#retrieve").attr("disabled", "true");
$.post(url, { message: message, queueName: queueName })
.success(function (response) {
renderSendMessageStatus(response);
updateMessageCountOf(queueName, response);
})
.error(function () { renderSendMessageStatus(false); });
});
});
function updateMessageCountOf(queueName, numberOfMessages) {
var message = numberOfMessages + " Messages";
if (numberOfMessages == "0") message = "No Messages";
if (numberOfMessages == "1") message = numberOfMessages + " Message";
$("div.msgCountOf" + queueName.replace(/ /g, '') + " > label").html(message);
}
function renderSendMessageStatus(response) {
if (response) $("#sendMessageStatus").html("Message sent successfully!");
else $("#sendMessageStatus").html("An error occurred, please try again later.");
$(".loading").hide();
$("#create").attr("disabled", "");
$("#retrieve").attr("disabled", "");
}
function updateMessageCountOf(queueName, numberOfMessages) {
var message = numberOfMessages + " Messages";
if (numberOfMessages == "0") message = "No Messages";
if (numberOfMessages == "1") message = numberOfMessages + " Message";
$("div.msgCountOf" + queueName.replace(/ /g, '') + " > label").html(message);
}
On the server side the SendMessage function will post our message.
[HttpPost]
public JsonResult SendMessage(String queueName, String message)
{
var _fullAddress = mBaseAddress + queueName + "/messages" + "?timeout=60";
var _webClient = GetWebClient();
_webClient.UploadData(_fullAddress, "POST", Encoding.UTF8.GetBytes(message));
return Json("1", JsonRequestBehavior.AllowGet);
}
Retrieve a Message
Finally to retrieve a message wee need to select a queue then send it to the server side. I modify this part of the code because I’m not using the brokeredMessage so I don't have all the properties from the original code lab.
How To Write Plugin in jQuery (Shakeel Iqbal | 28 Nov 2011 | Unedited contribution) - Yet another tutorial about creating a jQuery plugin. What is nice in this one is that is doing by iteration, starting with an empty plugin then adding bit of code to finish with some really great.
What the Heck Are Document Databases? - Really interesting article, that explain not only what are NoSql database but what you can do with it and some differences between them.
MongoDB (mongodb.org)
CouchDB (couchdb.apache.org)
RavenDB (ravendb.net)
An Alternative, Not a Replacement, for Relational Databases
BlobShare Sample: ACS-Protected File Sharing (Vittorio Bertocci - MSFT) - Nice complement to the Cover Cloud Show (episode 63). This post explain how the access control service works with BlobShare by following a scenario.
The Windows Azure HPC Scheduler also allows for job scheduling and resource management, web-based job submission, parallel runtimes with support for MPI applications and WCF services and persistent state management of job queue and resource configuration.
Invest in a diagnostics data viewing tool, such as Cerebrata, or grab a free trail of ManageAxis by following the rabbit hole from the Cloud Cover Show.
Read the full article on MSDN. http://blogs.msdn.com/b/windowsazure/archive/2011/11/09/new-article-best-practices-for-performance-improvements-using-service-bus-brokered-messaging.aspx
Wade Wegner - Some good tips about how to use some of the new feature in the azure SDK 1.6
Fleeting Thoughts - What is azure? How big and complete it is? This post try to pass-through all important knowledge that you should have before jumping... A good starting point.
The elastic nature of Windows Azure makes it suitable for generating load for a stress test. One such test setup is proposed in a series of blog posts by Ricardo.
In this post, I'm sharing my last (and first) Ruby script. The script is available on bitbicket here, and you can see the output result on any Reading Notes posts on my blog here: Reading Notes. I’m still learning Ruby, so feel free to leave me a comment. I will continue to update the script as I’m getting more comfortable with my new skill.
Starting Idea
If you are reading this post there is a good chance you already know that I’m posting every weeks a post about my weekly reading notes. I use Instapaper to bookmark all my reading stuff and send it to my Kindle. So order to make my weekly post I need to pass-through the “My Clippings.txt” file on my kindle, than go back on Instapaper, found the link to this article then put all this information together in a nice readable format.
So the idea was to speedup this process.
Kindle part
First thing first I need to retrieve all my notes in the “My Clippings.txt” file. I start trying to do it my self and the result was… not good. Then I found the really nice gem kindleclippings that was doing exactly what I want: parsing the file and give a array of all the notes with all the information about this note well organize with properties. So my job was to use it correctly… not to bad.
require 'kindleclippings'
parser = KindleClippings::Parser.new
clippings = parser.parse_file('My Clippings.txt')
#== Build the Html list ==
resume = "<ul>"
clippings.notes.each do |note|
resume << "\n<li>\n<b><a href=\"#\">#{note.book_title}</a></b> - #{note.content}\n"
resume << "#{GetBookHightlight(clippings.by_book(note.book_title))}\n</li>"
end
resume << "\n</ul>"
puts resume
As you can see nothing complicated, looping in the notes building a unsorted list (UL).
Instapaper part
Getting the reference link of the article is a little need more work. I need to login into Instapaper with my account, then found the matching bookmark. Once the good bookmark is found I need to extract url to the full article. In the same time I will move this bookmark to another folder to keep my “Unread” list short.
I'm using Watir to do my web scraping. This nice gem is very well done and can be use for testing user interfaces, but this will be in another post.
So first thing first I need to login. Here again nothing complexes get username and password and using it to login.
def InstapaperOpen()
browser = Watir::Browser.new
browser.goto 'http://www.instapaper.com/user/login'
puts "What is your Username? "
username ||= gets.chomp
puts "What is your Password? "
password ||= gets.chomp
browser.text_field(:name => 'username').set(username)
browser.text_field(:name => 'password').set(password)
browser.button(:type => 'submit').click
abort("Cannot login in Instapaper.") unless browser.link(:text => "Log out").exist?
return browser
end
def InstaPaperClose(browser)
browser.link(:text => "Log out").click
browser.close
end
Next, I need a method to search and return the bookmark matching my Kindle note.
So in SearchTitle method using regex I’m looking for an anchor <a> matching the title. If I didn’t found it I check if I found the “Older items >>” button to search deeper. I doing this calling recursively the method, until I found the matching bookmark or that no more “Older items >>” is present.
In MovePaperTo I click on the Move link in the context menu of the bookmark.
Finally putting all this together (with some improvements) and I got my final script! Nice way to practice the basic rules of Ruby. Of course it could be more clean more "rubist", but at least it works and I now I have something to practice my refactoring skill…
Feel free to leave me your comments or suggestions here on this blog or on Bitbuket.
A Comprehensive Introduction to Cloud Computing - This is a good introduction to what is the Cloud computing, using a real life analogy as starting point. (Unfortunately because of a blog restructuration the link is currently broken, but Wely did tell me that he will but it back soon.)
Microsoft announced the Windows Runtime (WinRT) stack at the heart of Windows 8 during the BUILD conference keynote in September, everyone in the room knew the game had changed.
Implementing Windows Azure Retry Logic (DavidAiken) – AzureSQL and Service Bus don't implement the retry. To have a good idea u cant use the framework explain in this post
"SQL Azure Reporting enables new hybrid IT scenarios - for example, customers can schedule automatic synchronization of on-premises databases with SQL Azure, and then deploy cloud-based BI reports based on the synchronized cloud-based data"
Reporting on Diagnostics Data(Joseph Fultz) – Wooo! A lot of stuff is going on here. grab your CTP access and download the code available in this article. great prove of concept.
Static Web Site Migration to Windows Azure(David Pallmann) - If you didn't know yet, here packaged in a 30 minutes recipe how to migrate a static web site. good way to move in the cloud AND saving money.
The Developer’s Guide to AppFabric (Alan Smith) - This is the official release version of “The Developer’s Guide to AppFabric” and it’s free.
"Microsoft’s Tony Meleg actually did an excellent job frankly discussing the future of the middle platformand their challenges of branding and cohesion. I strongly encourage you to watch that session"
How to Start Freelancing (Coby Chapple) – A series about doing some freelancing. the author share is experience. Read part1, part2, part3... still one more to come