今年的MIX09大会真的一天比一天振奋人心,ASP.NET MVC 1.0,Silverlight 3.0, IE 8等核武器级的微软神物纷纷发布。当然,本博客的主要任务是介绍Azure,其他的东东就让别人介绍去吧!
Windows Azure在MIX09上迎来了它的第3个CTP版本——March 2009 CTP,这个版本的更新非常之重要!先列举流牛木马认为其最重要的更新:
- 支持部署Full Trust的应用程序!甚至你还可以类似"%RoleRoot%”的Native Code、你可以访问进程、访问注册表!
- 支持FastCGI应用程序。这对于Azure的竞争对手Google AppEngine来说绝对是大规模杀伤性武器级的消息。FastCGI为何物?(请自行参考http://www.fastcgi.com)支持FastCGI,意味着Windows Azure上支持PHP、Python、Ruby等各种流行的web开发语言!
- URL Rewrite。这个版本的Azure提供了非常方便的URL Rewrite模块,只需要在web.config里稍做配置就可以了。
- 支持本地代码调试。 以前的Windows Azure不支持本地代码调试,这算是一个缺陷吧,现在弥补了。
在Windows Azure上跑PHP的效果图:
一段PHP操作Windows Azure Table Storage的示例代码:
function fetch($pkey) {
$date = gmdate('D, d M Y H:i:s \G\M\T');
$stringtosign = "GET\n\n\n$date\n/tweval/TagRatingTable()";
$signature = 'SharedKey tweval:'.base64_encode(
hash_hmac('sha256', $stringtosign, base64_decode($key),true));
$session = curl_init('http://tweval.table.core.windows.net/TagRatingTable()'
.'?$filter=PartitionKey%20eq%20\'' . urlencode($pkey) . '\'');
curl_setopt($session, CURLOPT_HTTPHEADER, array("x-ms-date:$date", "Authorization:$signature"));
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
curl_close($session);
$result = array();
foreach(simplexml_load_string($response)->entry as $entry) {
$properties =
$entry>content>children('http://schemas.microsoft.com/ado/2007/08/dataservices/metadata')
>properties>children('http://schemas.microsoft.com/ado/2007/08/dataservices');
$result[] = new Rating((string)($properties>Username), (int)($properties>StatusId),
(float)($properties>Score), (string)($properties>Tweet), new DateTime($properties>CreatedAt));
}
usort($result, 'cmp');
return $result;
}
$date = gmdate('D, d M Y H:i:s \G\M\T');
$stringtosign = "GET\n\n\n$date\n/tweval/TagRatingTable()";
$signature = 'SharedKey tweval:'.base64_encode(
hash_hmac('sha256', $stringtosign, base64_decode($key),true));
$session = curl_init('http://tweval.table.core.windows.net/TagRatingTable()'
.'?$filter=PartitionKey%20eq%20\'' . urlencode($pkey) . '\'');
curl_setopt($session, CURLOPT_HTTPHEADER, array("x-ms-date:$date", "Authorization:$signature"));
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
curl_close($session);
$result = array();
foreach(simplexml_load_string($response)->entry as $entry) {
$properties =
$entry>content>children('http://schemas.microsoft.com/ado/2007/08/dataservices/metadata')
>properties>children('http://schemas.microsoft.com/ado/2007/08/dataservices');
$result[] = new Rating((string)($properties>Username), (int)($properties>StatusId),
(float)($properties>Score), (string)($properties>Tweet), new DateTime($properties>CreatedAt));
}
usort($result, 'cmp');
return $result;
}
如果你是Python爱好者,你会惊喜地发现使用Python来操作Windows Azure的服务也是那么容易:
http://github.com/sriramk/winazurestorage/tree/master
下载Windows Azure Tools for Visual Studio and SDK(合二为一的安装文件): http://go.microsoft.com/fwlink/?LinkId=128752