标题说明了一切。我尝试了很多东西,但我认为它们中的任何一个都不值得一提。我终于想办法避免使用 Microsoft.WindowsAzure 并安装了 Microsoft.Azure.Management.Compute 和 Microsoft.Azure.Common 库。
我终于得到了这样的身份验证令牌:
var authenticationContext = new AuthenticationContext("https://login.windows.net/deadbeef-beef-beef-beef-ec74557498e8");
var credential = new ClientCredential("beefbeef-beef-beef-beef-b1d3cf5d037d", "passwordpasswordpasswordpasswordpasswordpas=");
var result = authenticationContext.AcquireTokenAsync("https://www.url.com/servicename", credential);
但是现在我正在努力使用文档来学习启动我的虚拟机。我什至不确定从哪里开始。我只知道我想避免使用 REST API 并将我的代码保留在 C# 中。我正在寻找类似的东西:
using (var client = new ComputeManagementClient(creds)) {
foreach (var vm in client.VMs)
{
Console.WriteLine("Starting VM: {0}", vm.Name);
vm.PowerOn();
}
}