Created
October 14, 2018 18:22
-
-
Save buchizo/b732c417812ea7bb3c3789d494aac2c7 to your computer and use it in GitHub Desktop.
MSI Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Azure.Management.WebSites; | |
using Microsoft.Azure.Services.AppAuthentication; | |
using Microsoft.Rest; | |
using System; | |
using System.Linq; | |
using System.Threading.Tasks; | |
namespace ConsoleApp3 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Task.Run(async () => | |
{ | |
try | |
{ | |
var tokenp = new AzureServiceTokenProvider(); | |
var at = await tokenp.GetAccessTokenAsync("https://management.azure.com/"); | |
var c = new WebSiteManagementClient(new TokenCredentials(at)) | |
{ | |
SubscriptionId = "REPLACE MY SUBSCRIPTION ID" | |
}; | |
var apps = await c.WebApps.ListAsync(); | |
Console.WriteLine(apps.ToList().First().Name); | |
} | |
catch (Exception ex) | |
{ | |
Console.WriteLine(ex.Message); | |
} | |
}).Wait(); | |
Console.ReadKey(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment