Azure Management API 之 利用 Windows Azure Management Libraries 来控制Azure platform
在此之前,我曾经发过一篇文章讲叙了如何利用Azure power shell team 提供的class library。
而就在这篇文章发布之后不久,我又发现微软发布了一个preview 版本的Windows Azure Management Libraries For .NET Nuget package来帮助.NET 开发人员来更好的控制Auzre Platform。
相比power shell team使用的library, Windows Azure Management Libraries For .NET 将业务逻辑更好的划分了开来,同时也使用了最新的Async programing来替代.net 4.5之前非常流行的异步委托编程方式。
很明显,这个class library今后将融入Azure SDK 之中,成为替代.NET 程序员直接调用Azure Management REST API的最佳选择。
那么就让我们来了解一下如何使用这个libararies吧。
一、添加Nuget Packages到项目中
新建一个Console应用程序,打开Tools->Library pPackage Manager->Package Manager Console.

然后输入以下命令行来安装该package:
Install-Package Microsoft.WindowsAzure.Management.Libraries -Pre
接下来我们将通过几个示例来了解如何使用这个library,首先让我们来获取Azure portal下所有Host service 的名字吧!
二、利用Compute Management Client 获取Azure platform下所有Azure cloud service host Name
首先,我们需要登录以下链接来获取与Azure 平台交互所需的publishsettings file
https://manage.windowsazure.com/publishsettings/index?client=vs&schemaversion=2.0
打开Console程序创建如下代码
using Microsoft.WindowsAzure.Management.Compute;
using Microsoft.WindowsAzure.Management;
using Microsoft.WindowsAzure;
using System.Security.Cryptography.X509Certificates; namespace ListCloudServiceName
{
class Program
{
public const string base64EncodedCertificate = "<Your PublishSettings file ManagementCertificate property's Value>";
public const string subscriptionId = "<You Azure subscription id>"; static void Main(string[] args)
{
getAllCloudServicesName();
Console.ReadLine();
} public static void getAllCloudServicesName()
{
ComputeManagementClient client = new ComputeManagementClient(getCredentials());
var cloudServiceList=client.HostedServices.List();
foreach (var cloudService in cloudServiceList)
{
Console.WriteLine(cloudService.ServiceName);
}
} static SubscriptionCloudCredentials getCredentials()
{
return new CertificateCloudCredentials(subscriptionId,new X509Certificate2(Convert.FromBase64String(base64EncodedCertificate)));
}
}
}
将publishsetting中的 ManagementCertificate 属性的值与id属性的值分别填入上面代码之中。
这样一个简单的获取所有cloud Service name的程序就完成了。
这里调用的是client.HostedServices.List()方法, 这个方法是一个extension method。
微软把与Azure Management REST API对应的一些方法都写成了extension method方便我们的调用。
而且微软将不同的技术都做了层层划分,首先是dll分成了5个,然后再在dll内将不同的技术划分开来方便了不同的.net 开发人员来进行调用,更具有针对性了。
由于目前这个package 刚刚推出,并没有多少的文档来详细阐述如何使用这个它, 我会在之后的blog中,针对我日常常用的一些操作来进行阐述,希望更多.net 开发人员能够使用上这个非常不错的类, 从而结束不停的send http web request。。。
Azure Management API 之 利用 Windows Azure Management Libraries 来控制Azure platform的更多相关文章
- Windows Server: 将虚拟机迁移到 Azure (以阿里云为例)
Azure 虚拟机能很容易地导出 vhd 并迁移到各种环境中,包含本地及云端环境,或者迁移至其他区域.这为开发.测试.扩展带来了极大的便利.本文以阿里云为例,阐述如何将Windows Server 的 ...
- C#码农的大数据之路 - 使用Azure Management API创建HDInsight集群
Azure平台提供了几乎全线产品的API,可以使用第三方工具来进行管理.对于.NET更是提供封装好了的库方便使用C#等语言实现Azure的管理. 我们使用创建HDInsight集群为例来介绍使用C#管 ...
- [Windows Azure] Managing SQL Database using SQL Server Management Studio
Managing Windows Azure SQL Database using SQL Server Management Studio You can use Windows Azure SQL ...
- 【Azure API 管理】解决API Management添加AAD Group时遇见的 Failed to query Azure Active Directory graph due to error 错误
问题描述 为APIM添加AAD Group时候,等待很长很长的时间,结果添加失败.错误消息为: Write Groups ValidationError :Failed to query Azure ...
- Windows Azure Mangement API 之 更方便的使用Mangement API
许多.Net 程序员在使用Azure Management API的时候都选择参考微软官方示例,通过创建HttpWebRequest来创建. 或者自己创建类库来封装这些API,使之调用起来更加方便. ...
- [Windows Azure] Using the Graph API to Query Windows Azure AD
Using the Graph API to Query Windows Azure AD 4 out of 4 rated this helpful - Rate this topic This d ...
- Azure REST API (1) 前言
<Windows Azure Platform 系列文章目录> 一.服务运行时API简介 微软的Windows Azure服务总线提供了一整套REST风格的API,其中包括服务运行时API ...
- 使用 Puppet 在 Windows Azure 中配备 Linux 和 Windows 环境
发布于 2013-12-11 作者 Ross Gardler 微软开放技术有限公司 (MS Open Tech) 很高兴地宣布发行新的 Windows Azure Puppet 模块.通过这个模 ...
- Azure REST API (3) 使用REST API,操作Azure ARM VM
<Windows Azure Platform 系列文章目录> 笔者之前遇到一个客户,需求是当发生某一个特定条件的时候,对多台Azure ARM VM执行开机或者关机操作,这个时候就需要使 ...
随机推荐
- Apache Flink初接触
Apache Flink闻名已久,一直没有亲自尝试一把,这两天看了文档,发现在real-time streaming方面,Flink提供了更多高阶的实用函数. 用Apache Flink实现WordC ...
- Mac&iOS之多线程--转自http://geeklu.com/2012/02/thread/
http://geeklu.com/2012/02/thread/ 首先循环体的开始需要检测是否有需要处理的事件,如果有则去处理,如果没有则进入睡眠以节省CPU时间. 所以重点便是这个需要处理的事件, ...
- 记一次程序排错与std::getline
今天忙活了半个下午,查找正式环境上面一个程序的问题.这个程序的作用是监控文件夹,处理每一个文件,分析每个文件的每行记录,然后将这个文件拆分成两个结果文件投放到另外两个不同的目录下面去,当处理完这个文件 ...
- Bad Request - Request Too Long
Bad Request - Request Too Long HTTP Error 400. The size of the request headers is too long. 该错误原因导致 ...
- Oracle数据库基础知识2
字符操作相关_1 1.CONCAT关键字作用:连接字符串语法:CONCAT(字串1, 字串2)例如: CONCAT('hello','world') FROM DUAL; 注意:Oracle的CONC ...
- quicksort
快排.... void quicksort(int *a,int left,int right){ if(left >= right){ return ; } int i = left; int ...
- source insight 编程风格(持续更新)
1.字体Source Code Pro 出身于豪门Adobe,从名字上来看就知道是转为编码而生的.基本上也是拥有前面所提的编程字体的所有要素的.这个字体基本上具有编程字体所需的所有要素:等宽.支持Cl ...
- Java中OutOfMemoryError(内存溢出)的三种情况及解决办法
转载自:http://blog.sina.com.cn/s/blog_701c951f0100n1sp.html 相信有一定java开发经验的人或多或少都会遇到OutOfMemoryError的问题, ...
- blowfish ECB decode
blowfish ECB Decode package main import ( "crypto/cipher" "encoding/hex" " ...
- jquery中css获取颜色属性
Jquery获取颜色的方法为: var color = $(元素).css("color"); alert(color); 可以看到color如这样的格式; 但是; 因为rgb(0 ...