Skip to content

Commit 7b22228

Browse files
committed
fix RGName issue
1 parent 66c25ef commit 7b22228

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecApiClient.ps1

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,8 @@ function Invoke-ExecApiClient {
100100
}
101101
'GetAzureConfiguration' {
102102
$Owner = $env:WEBSITE_OWNER_NAME
103-
$RGName = $env:WEBSITE_RESOURCE_GROUP
104-
if (!$RGName) {
105-
$RGName = $Owner -split '\+' | Select-Object -Last 1
106-
$RGName = $RGName -replace '-[^-]+$', ''
103+
if ($Owner -match '^(?<SubscriptionId>[^+]+)\+(?<RGName>[^-]+(?:-[^-]+)*?)(?:-[^-]+webspace(?:-Linux)?)?$') {
104+
$RGName = $Matches.RGName
107105
}
108106
$FunctionAppName = $env:WEBSITE_SITE_NAME
109107
try {
@@ -121,10 +119,9 @@ function Invoke-ExecApiClient {
121119
}
122120
'SaveToAzure' {
123121
$TenantId = $env:TenantId
124-
$RGName = $env:WEBSITE_RESOURCE_GROUP
125-
if (!$RGName) {
126-
$RGName = $Owner -split '\+' | Select-Object -Last 1
127-
$RGName = $RGName -replace '-[^-]+$', ''
122+
$Owner = $env:WEBSITE_OWNER_NAME
123+
if ($Owner -match '^(?<SubscriptionId>[^+]+)\+(?<RGName>[^-]+(?:-[^-]+)*?)(?:-[^-]+webspace(?:-Linux)?)?$') {
124+
$RGName = $Matches.RGName
128125
}
129126
$FunctionAppName = $env:WEBSITE_SITE_NAME
130127
$AllClients = Get-CIPPAzDataTableEntity @Table -Filter 'Enabled eq true' | Where-Object { ![string]::IsNullOrEmpty($_.RowKey) }

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecBackendURLs.ps1

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ Function Invoke-ExecBackendURLs {
1818
# Write to the Azure Functions log stream.
1919
Write-Host 'PowerShell HTTP trigger function processed a request.'
2020

21-
$RGName = $env:WEBSITE_RESOURCE_GROUP
22-
if (!$RGName) {
23-
$Owner = $env:WEBSITE_OWNER_NAME
24-
$RGName = $Owner -split '\+' | Select-Object -Last 1
25-
$RGName = $RGName -replace '-[^-]+$', ''
21+
$Owner = $env:WEBSITE_OWNER_NAME
22+
if ($Owner -match '^(?<SubscriptionId>[^+]+)\+(?<RGName>[^-]+(?:-[^-]+)*?)(?:-[^-]+webspace(?:-Linux)?)?$') {
23+
$RGName = $Matches.RGName
2624
}
2725

2826
$results = [PSCustomObject]@{

0 commit comments

Comments
 (0)