private async void GetApiAppsInSubscription()
{
if (Wizard.Pages.Any(x => x.Legend == Resources.Page1Legend && x.IsSelected))
{
using (Context.StartBusyIndicator(Resources.WaitMessageGettingApiApps))
{
IAzureRMUserAccountSubscriptionContext sub = _selectedSubscription;
if (sub == null)
{
ApiApps = new List<ApiAppResource>();
return;
}
Token = await sub.GetAuthenticationHeaderAsync(true);
Token = Token.Substring("Bearer ".Length);
var apiApps = new List<ApiAppResource>();
using (var httpClient = new HttpClient())
{
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Token);
var url = string.Format(Constants.URL_APP_SERVICES_WITH_METADATA_DEFINITION, sub.Subscription.SubscriptionId);
var json = httpClient.GetStringAsync(new Uri(url)).Result;
var job = JObject.Parse(json);
var apps = (JArray)job["value"];
foreach (var app in apps)
{
try
{
apiApps.Add(new ApiAppResource
{
Name = app["name"].Value<string>(),
ResourceGroup = Utility.ResourceUtilities.GetResourceGroupFromResourceId(
app["id"].Value<string>()
),
ResourceId = app["id"].Value<string>(),
SwaggerUrl = app["properties"]["siteConfig"]["apiDefinition"]["url"].Value<string>()
});
}
catch
{
}
}
}
_dispatcher.Invoke(() => ApiApps = apiApps);
}
if (ApiApps.Any())
{
Wizard.IsNextEnabled = true;
}
}
}