Created
June 13, 2025 15:39
-
-
Save TheCloudScout/40f4d6d9c4fc0f349c014ad85dcef230 to your computer and use it in GitHub Desktop.
Deploy-SecurityCopilotSCUs.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
[string]$ResourceGroupName = "RG-SecurityCopilot", | |
[string]$CapacityName = "scu-bitdefend-01", | |
[string]$Location = "westeurope", | |
[string]$Geo = "EU", # This is the prompt evaluation location. Choose either: EU, US, UK, ANZ | |
[string]$ApiVersion = "2024-11-01-preview" | |
) | |
function Deploy-SecurityCopilotSCUs { | |
[int]$Units = Read-Host "How many SCUs do you want to deploy?" | |
[int]$OverageUnits = Read-Host "How many overage SCUs do you want to reserve (can be 0)?" | |
# Check and register the resource provider if not already registered | |
$providerNamespace = "Microsoft.SecurityCopilot" | |
Write-Host "π Checking if resource provider '$providerNamespace' is registered..." | |
$provider = Get-AzResourceProvider -ProviderNamespace $providerNamespace | |
if ($provider.RegistrationState -ne "Registered") { | |
Write-Host "β οΈ Resource provider '$providerNamespace' is not registered. Registering now..." | |
Register-AzResourceProvider -ProviderNamespace $providerNamespace | |
# Wait until itβs registered (poll every 5 sec) | |
do { | |
Start-Sleep -Seconds 5 | |
$provider = Get-AzResourceProvider -ProviderNamespace $providerNamespace | |
Write-Host "β³ Waiting for provider registration... Current status: $($provider.RegistrationState)" | |
} while ($provider.RegistrationState -ne "Registered") | |
Write-Host "β Resource provider '$providerNamespace' registered successfully." | |
} else { | |
Write-Host "β Resource provider '$providerNamespace' is already registered." | |
} | |
# Ensure resource group exists | |
if (-not (Get-AzResourceGroup -Name $ResourceGroupName -ErrorAction SilentlyContinue)) { | |
Write-Host "Creating resource group $ResourceGroupName..." | |
New-AzResourceGroup -Name $ResourceGroupName -Location $Location | |
} | |
# Define SCU properties | |
$properties = @{ | |
numberOfUnits = $Units | |
overageState = "Limited" # or "Unlimited" | |
overageAmount = $OverageUnits | |
geo = $Geo | |
crossGeoCompute = "NotAllowed" # or "Allowed" | |
} | |
# Create or update SCU capacity | |
Write-Host "π Deploying SCU capacity '$CapacityName' with $Units units in $Location..." | |
New-AzResource ` | |
-ResourceType "Microsoft.SecurityCopilot/capacities" ` | |
-ApiVersion $ApiVersion ` | |
-ResourceGroupName $ResourceGroupName ` | |
-ResourceName $CapacityName ` | |
-PropertyObject $properties ` | |
-Location $Location ` | |
-Force | |
Write-Host "β SCU deployment completed." | |
} | |
function Remove-SecurityCopilotSCUs { | |
Write-Host "ποΈ Removing SCU capacity '$CapacityName'..." | |
Remove-AzResource ` | |
-ResourceType "Microsoft.SecurityCopilot/capacities" ` | |
-ApiVersion $ApiVersion ` | |
-ResourceGroupName $ResourceGroupName ` | |
-ResourceName $CapacityName ` | |
-Force | |
Write-Host "β SCU capacity removed." | |
} | |
# Ensure Azure context exists --- | |
if (-not (Get-AzContext)) { | |
Write-Host "π No Azure session found. Launching login prompt..." | |
Connect-AzAccount | |
} else { | |
Write-Host "β Azure session found. Using existing context." | |
} | |
# Call the deployment function | |
Deploy-SecurityCopilotSCUs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment