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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
雷峰网
雷峰网
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Spread Privacy
Spread Privacy
H
Hacker News: Front Page
PCI Perspectives
PCI Perspectives
Webroot Blog
Webroot Blog
罗磊的独立博客
H
Heimdal Security Blog
TaoSecurity Blog
TaoSecurity Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
大猫的无限游戏
大猫的无限游戏
月光博客
月光博客
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Google Online Security Blog
Google Online Security Blog
Last Week in AI
Last Week in AI
美团技术团队
Help Net Security
Help Net Security
The Hacker News
The Hacker News
C
Cisco Blogs
T
The Blog of Author Tim Ferriss
J
Java Code Geeks
The Register - Security
The Register - Security
IT之家
IT之家
WordPress大学
WordPress大学
Jina AI
Jina AI
Recent Commits to openclaw:main
Recent Commits to openclaw:main
H
Help Net Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Threat Research - Cisco Blogs
P
Proofpoint News Feed
NISL@THU
NISL@THU
爱范儿
爱范儿
The GitHub Blog
The GitHub Blog
Scott Helme
Scott Helme
V
Vulnerabilities – Threatpost
B
Blog
T
Tenable Blog
博客园 - 三生石上(FineUI控件)
T
The Exploit Database - CXSecurity.com
S
Security Affairs
小众软件
小众软件
Hacker News: Ask HN
Hacker News: Ask HN
Security Latest
Security Latest
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
W
WeLiveSecurity
A
Arctic Wolf
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
M
MIT News - Artificial intelligence

博客园 - 鞠强

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