public async System.Threading.Tasks.Task <IActionResult> Index() { ViewData["SubscriptionId"] = subscription_id; try { var token = await MsiHelper.GetToken("https://storage.azure.com/"); ViewData["BlobTokenStatus"] = string.IsNullOrEmpty(token) ? "Failed to get token for storage.azure.com/" : "Got an ARM token for storage.azure.com/"; ViewData["DecodedToken"] = JwtHelper.DecodeToJson(token); if (string.IsNullOrEmpty(token)) { ViewData["Containers"] = "Get StorageToken was unsuccessful"; } else { ViewData["ContainersXML"] = AzureStorageHelper.GetAllContainerNamesXml(token, storage_account); } } catch (Exception ex) { Console.WriteLine(ex.Message); ViewData["Exception"] = ex?.Message; ViewData["InnerException"] = ex?.InnerException?.Message; } return(View()); }
public async Task <IActionResult> Index() { ViewData["SubscriptionId"] = subscription_id; try { var token = await GetToken("https://management.azure.com/"); ViewData["ARMTokenStatus"] = "Got a token!"; ViewData["DecodedToken"] = JwtHelper.DecodeToJson(token); var rgs = await GetResourceGroups(token); ViewData["ResourceGroups"] = new List <string>(rgs.Select(r => r.Name)); // must cast correctly var providers = await GetProviders(token); ViewData["Providers"] = new List <string>(providers.Select(p => p.Id)); var resources = await GetAllResources(token); ViewData["Resources"] = new List <string>(resources.Select(r => r.Type + "-" + r.Name)); } catch (Exception ex) { Console.WriteLine(ex.Message); ViewData["ARMTokenStatus"] = "Error Getting ARM Token"; } return(View()); }