Skip to content

Commit edaa6df

Browse files
author
Mike Swantek
committed
sanitised the parameters
added a silent continue when a rg no longer exists for Foundry resources
1 parent 3118c7f commit edaa6df

5 files changed

Lines changed: 15 additions & 6 deletions

File tree

infra/main.bicepparam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ param dagaTags = [
1010
'foundry'
1111
]
1212
param dagaConnectM365 = true
13-
param dagaM365UserPrincipalName = 'admin@MngEnv282784.onmicrosoft.com'
13+
param dagaM365UserPrincipalName = ''
1414
param dagaM365AppId = ''
1515
param dagaM365Organization = ''
1616
param dagaM365CertificateThumbprint = ''

scripts/defender/defenderForAI/07-Enable-Diagnostics.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ $workspaceResourceId = Resolve-WorkspaceResourceId -workspaceId $law -specObj $s
6161

6262
foreach($r in $spec.foundry.resources){
6363
if(!$r.diagnostics){ continue }
64-
$res = Get-AzResource -ResourceId $r.resourceId -ErrorAction Stop
64+
$res = Get-AzResource -ResourceId $r.resourceId -ErrorAction SilentlyContinue
65+
if(-not $res){
66+
Write-Warning "Resource not found, skipping: $($r.resourceId)"
67+
continue
68+
}
6569
$diagResourceId = Get-DiagnosticScopeId -resourceId $r.resourceId
6670
$scopeName = if($diagResourceId -eq $r.resourceId){ $res.Name } else { (Split-Path -Path $diagResourceId -Leaf) }
6771
$name = "$scopeName-diag"

scripts/governance/dspmPurview/25-Tag-ResourcesFromSpec.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ if ($spec.foundry -and $spec.foundry.resources) {
1515
else{ foreach($prop in $r.tags.PSObject.Properties){ $desiredTags[$prop.Name] = $prop.Value } }
1616
}
1717
if($desiredTags.Count -eq 0){ Write-Host "No spec tags defined for $($r.name); skipping" -ForegroundColor DarkGray; continue }
18-
19-
$res = Get-AzResource -ResourceId $r.resourceId -ErrorAction Stop
18+
$res = Get-AzResource -ResourceId $r.resourceId -ErrorAction SilentlyContinue
19+
if(-not $res){ Write-Warning "Resource not found, skipping tag update: $($r.resourceId)"; continue }
2020
if($res.ResourceType -and $res.ResourceType -match '/projects'){ Write-Host "Skipping tag update for project-level resource $($res.ResourceId); Azure tags only apply to the parent account." -ForegroundColor Yellow; continue }
2121
$merged = @{}
2222
if($res.Tags -is [Collections.IDictionary]){ $merged += $res.Tags }

scripts/governance/dspmPurview/30-Foundry-RegisterResources.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ Ensure-AzContext -TenantId $spec.tenantId -SubscriptionId $spec.subscriptionId
99
if(-not $spec.foundry -or -not $spec.foundry.resources){ Write-Host "No foundry.resources"; exit 0 }
1010
foreach($r in $spec.foundry.resources){
1111
if(-not $r.resourceId -or $r.resourceId -notmatch '/projects/'){ Write-Host "Skipping non-Foundry resource: $($r.name)" -ForegroundColor Yellow; continue }
12-
$res = Get-AzResource -ResourceId $r.resourceId -ErrorAction Stop
12+
$res = Get-AzResource -ResourceId $r.resourceId -ErrorAction SilentlyContinue
13+
if(-not $res){
14+
Write-Warning "Resource not found, skipping: $($r.resourceId)"
15+
continue
16+
}
1317
Write-Host "Found resource: $($res.ResourceId)" -ForegroundColor Cyan
1418
if($r.tags){
1519
$merged = @{}

scripts/governance/dspmPurview/31-Foundry-ConfigureContentSafety.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ $base = $cs.endpoint.TrimEnd('/')
1313
$headers = @{}
1414
$hasKey = $cs.apiKeySecretRef -and $cs.apiKeySecretRef.keyVaultResourceId -and $cs.apiKeySecretRef.secretName
1515
if($hasKey){
16-
$kvRes = Get-AzResource -ResourceId $cs.apiKeySecretRef.keyVaultResourceId -ErrorAction Stop
16+
$kvRes = Get-AzResource -ResourceId $cs.apiKeySecretRef.keyVaultResourceId -ErrorAction SilentlyContinue
17+
if(-not $kvRes){ Write-Warning "Key Vault not found, skipping Content Safety key fetch: $($cs.apiKeySecretRef.keyVaultResourceId)"; exit 0 }
1718
$kvName = ($kvRes.ResourceId -split "/")[-1]
1819
$apiKey = (Get-AzKeyVaultSecret -VaultName $kvName -Name $cs.apiKeySecretRef.secretName -ErrorAction Stop).SecretValueText
1920
$headers["Ocp-Apim-Subscription-Key"] = $apiKey

0 commit comments

Comments
 (0)