Skip to content

Commit eca34a3

Browse files
committed
Fix Azure SDK API compilation errors and enable Portal execution
- Fix Pageable<GenericResource> to use foreach instead of await foreach - Fix AzureLocation access pattern to remove null coalescing operator - Add missing _armClient field and Azure.Core using statement in CosmosDiscoveryService - Add proper ResourceIdentifier usage for subscription access - Portal now runs successfully on port 5010 - All live data discovery services compile and execute properly
1 parent c973112 commit eca34a3

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

management-portal/src/Portal/Services/AzureInfrastructureService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ public async Task<InfrastructureDiscoveryResult> DiscoverInfrastructureAsync()
6262

6363
// Get all resources in this resource group
6464
var rgResources = resourceGroup.GetGenericResources();
65-
await foreach (var resource in rgResources)
65+
foreach (var resource in rgResources)
6666
{
6767
var discoveredResource = new DiscoveredResource
6868
{
6969
Id = resource.Id.ToString(),
7070
Name = resource.Data.Name,
7171
Type = resource.Data.ResourceType.ToString(),
72-
Location = resource.Data.Location?.Name ?? "unknown",
72+
Location = resource.Data.Location.Name,
7373
ResourceGroup = resourceGroup.Data.Name
7474
};
7575
resources.Add(discoveredResource);
@@ -148,7 +148,7 @@ private bool IsStampsResourceGroup(string resourceGroupName)
148148
var resourceCount = 0;
149149

150150
var resources = resourceGroup.GetGenericResources();
151-
await foreach (var resource in resources)
151+
foreach (var resource in resources)
152152
{
153153
resourceCount++;
154154
var resourceType = resource.Data.ResourceType.ToString();

management-portal/src/Portal/Services/CosmosDiscoveryService.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Azure.Identity;
33
using Azure.ResourceManager;
44
using Azure.ResourceManager.Resources;
5+
using Azure.Core;
56

67
namespace Stamps.ManagementPortal.Services;
78

@@ -17,6 +18,7 @@ public class CosmosDiscoveryService : ICosmosDiscoveryService
1718
private readonly ILogger<CosmosDiscoveryService> _logger;
1819
private readonly IConfiguration _configuration;
1920
private readonly IDataService _dataService;
21+
private readonly ArmClient _armClient;
2022

2123
public CosmosDiscoveryService(
2224
ILogger<CosmosDiscoveryService> logger,
@@ -26,6 +28,7 @@ public CosmosDiscoveryService(
2628
_logger = logger;
2729
_configuration = configuration;
2830
_dataService = dataService;
31+
_armClient = new ArmClient(new DefaultAzureCredential());
2932
}
3033

3134
public async Task<List<Tenant>> DiscoverTenantsAsync()
@@ -312,10 +315,11 @@ private async Task<string> DetermineCellId(ResourceGroupResource resourceGroup)
312315
{
313316
// Look for related cell/stamp resource groups in the same region
314317
var location = resourceGroup.Data.Location.Name;
315-
var subscription = resourceGroup.Parent;
318+
var subscriptionId = resourceGroup.Id.SubscriptionId;
319+
var subscription = _armClient.GetSubscriptionResource(new ResourceIdentifier($"/subscriptions/{subscriptionId}"));
316320

317321
var resourceGroups = subscription.GetResourceGroups();
318-
await foreach (var rg in resourceGroups)
322+
foreach (var rg in resourceGroups)
319323
{
320324
if (IsCellResourceGroup(rg.Data.Name) && rg.Data.Location.Name == location)
321325
{
@@ -363,7 +367,7 @@ private async Task<string> DetermineCellHealth(ResourceGroupResource resourceGro
363367
var resourceCount = 0;
364368
var criticalResourceCount = 0;
365369

366-
await foreach (var resource in resources)
370+
foreach (var resource in resources)
367371
{
368372
resourceCount++;
369373
var resourceType = resource.Data.ResourceType.ToString();
@@ -396,7 +400,7 @@ private async Task<string> DetermineCellHealth(ResourceGroupResource resourceGro
396400
var resources = resourceGroup.GetGenericResources();
397401
var resourceCount = 0;
398402

399-
await foreach (var resource in resources)
403+
foreach (var resource in resources)
400404
{
401405
resourceCount++;
402406
}

0 commit comments

Comments
 (0)