惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Application and Cybersecurity Blog
Application and Cybersecurity Blog
N
News | PayPal Newsroom
The Last Watchdog
The Last Watchdog
S
Secure Thoughts
Forbes - Security
Forbes - Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
PCI Perspectives
PCI Perspectives
N
News and Events Feed by Topic
Hacker News - Newest:
Hacker News - Newest: "LLM"
Last Week in AI
Last Week in AI
Blog — PlanetScale
Blog — PlanetScale
Hacker News: Ask HN
Hacker News: Ask HN
H
Heimdal Security Blog
D
Docker
Cloudbric
Cloudbric
P
Privacy International News Feed
S
Security Affairs
TaoSecurity Blog
TaoSecurity Blog
博客园 - 聂微东
WordPress大学
WordPress大学
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
Tenable Blog
Scott Helme
Scott Helme
人人都是产品经理
人人都是产品经理
Recent Announcements
Recent Announcements
P
Palo Alto Networks Blog
小众软件
小众软件
L
LINUX DO - 最新话题
美团技术团队
Google Online Security Blog
Google Online Security Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
雷峰网
雷峰网
Microsoft Security Blog
Microsoft Security Blog
The Hacker News
The Hacker News
Webroot Blog
Webroot Blog
T
Tor Project blog
G
Google Developers Blog
A
About on SuperTechFans
Y
Y Combinator Blog
K
Kaspersky official blog
A
Arctic Wolf
量子位
I
InfoQ
V
Visual Studio Blog
T
Troy Hunt's Blog
C
Cybersecurity and Infrastructure Security Agency CISA
J
Java Code Geeks
博客园 - 【当耐特】
GbyAI
GbyAI

博客园 - 鞠强

HBase初探 HDInsight - 1,简介 Windows8.1画热度图 - 坑 使用windbg查看DependencyObject的属性 LiveSDK初始化/登录时失败的解决办法 开发WP版本的大菠萝英雄榜 SQL 2014 in-memory中的storage部分 XAML绑定 Kinect 1 Diablo3狗熊榜 微软上海招聘有经验的.NET开发人员 塔防蜀的存档分析 我的HD2手机 和我一起作Tess的windbg lab,结束 和我一起作Tess的windbg lab - Lab7, MemoryLeak 和我一起作Tess的windbg lab - Lab6, MemoryLeak 和我一起作Tess的windbg lab - Lab5, Crash 和我一起作Tess的windbg lab - Lab4, High CPU 和我一起作Tess的windbg lab - Lab3, Memory
C#访问Azure的资源
鞠强 · 2015-08-18 · via 博客园 - 鞠强

官方参考资料在这里:https://msdn.microsoft.com/en-us/library/azure/dn722415.aspx,本文放一些重点及遇到的坑的解决办法。

身份验证

不是说,我们把subscriptionID和本地的cert匹配一下就OK了,还需要在portal中配置,允许我们的APP访问这个portal。主要参考这里:Add an application to Azure AD。要注意的是,上文是4月15日的版本,但是现在(8月18日)的版本,已经不是在Set up directory这个TAB页上,而是在Develop Applications这个TAB上。 

在OAuth的回调页面中,不是两个URL,而是变成了一个,这里我写了http://localhost/。七月的,配置permission的时候,照做即可,别忘记点下面的保存。

添加引用

在VS工程里面,按照上面指南,management libraries是没问题的。但是注意第二个,AD auth的,搜索之后找到的,不是原文中的Active Directory Authentication Library,而是Microsoft.IdentityModel.Clients.ActiveDirectory(我擦,整天改名字,好玩吗?!)

修改配置

按照指南,把那一坨appSettings内容添加到app.config文件中,然后把OAUTH2对应的endpoint的GUID替换到app.config中的id-of-tenent。在另一个portal界面中,把id-of-client的值也替换到app.config文件中。

截止到step7为止,替换redirectUri遗迹subScriptionId。step8及之后,暂时不修改。

Token

按照指南做即可。此时就可以做验证了,在你的入口方法中调用GetAuthorizationHeader,如果能弹出来微软的ADFS认证窗口,并且你输入你自己的azure的管理员账号与密码,验证成功后,那么就没问题了。

这时,可以初步验证我们的代码了:

        private void button1_Click(object sender, EventArgs e)
        {
            var token = GetAuthorizationHeader();
            var credential = new TokenCloudCredentials(ConfigurationManager.AppSettings["subscriptionId"], token);

            var computeClient = new Microsoft.WindowsAzure.Management.Compute.ComputeManagementClient(credential);
            var services = computeClient.HostedServices.List().HostedServices;
        }

View Code