← All articles
Microsoft Sentinel · Step-by-step guide

Automate Microsoft Sentinel Content Hub and Analytics Rule Updates with Azure Automation

Replace repetitive Sentinel maintenance with scheduled update jobs and a controlled detection-change review process.

# Automate Microsoft Sentinel Content Hub and Analytics Rule Updates with Azure Automation

The operational challenge

I was spending time manually checking installed Content Hub solutions for updates, then checking active analytics rules to see whether newer detection templates were available. Updating the packages did not automatically update the active rules. Maintaining both meant repeating the same checks and changes, alongside normal security operations.

To remove that recurring maintenance hassle, I set up Azure Automation to handle Content Hub and analytics-rule updates. Rather than continually revisiting the portal, the aim was to make update checks a scheduled operational process.

The PowerShell update engines are credited to Charbel Nemnom's reference guides and Willem-Jan van Esschoten's contributions to the analytics-rule updater. The upstream authors also describe running the package updater before the rule updater; that sequence is not an original invention of mine. My contribution was applying the approach to my operational maintenance problem. This walkthrough adds a proposed change-control and validation framework for readers. The original tenant and runbook logs are no longer accessible, so the additional safeguards below are recommendations, not claims that they were implemented historically.

What you'll accomplish: Set up a two-stage update process that checks Content Hub versions before evaluating changes to active Sentinel analytics rules.

Before you begin

Verify the result: Confirm both runbooks report expected updates/skips, keep the same active rule IDs and preserve required KQL, mappings and scheduling.

Understand why two update jobs are required

Microsoft Sentinel analytics rule templates and active analytics rules are not dynamically linked. Installing a newer Content Hub solution can make a newer rule template available, but an active rule created previously does not automatically inherit those changes.

A maintainable workflow has two stages:

  1. Content Hub update: assess installed solutions and update packages when a newer version is available.
  2. Active analytics-rule review and update: compare enabled scheduled rules with their source templates and decide which can safely be updated.

The sequence matters. Run the solution updater first; only then assess the active rules against the updated templates. Updating a solution alone should not be reported as proof that every active rule has been upgraded.

Step 1 — Prepare the Automation Account and permissions

The vendor-guided design is documented in Automate Microsoft Sentinel Content Hub Updates and Update Microsoft Sentinel Analytics Rules at Scale. These are attributed reference implementations; the scripts remain the upstream authors' work.

Step 2 — Review installed Content Hub solutions

Before configuring any write action, inventory the solutions already installed in the workspace. Note each solution's installed version, latest available version, preview status and any dependencies or integration-specific customisation.

Check the current Microsoft Sentinel interface, as the portal and API experiences have changed since older scripts were published. A version comparison should parse semantic versions numerically, not use ordinary string ordering: for example, 3.0.10 is newer than 3.0.9 even if a lexicographical comparison says otherwise.

Check the upstream release notes for fixes affecting version comparison before deploying an approved revision.

Step 3 — Configure the two PowerShell runbooks

Create or inspect an Automation Account in an approved subscription. Enable its system-assigned managed identity and grant only the resource permissions required for the target Sentinel workspace, avoiding subscription-wide Contributor access where a narrower scope is sufficient. Use a supported PowerShell runtime and verified compatible Az modules.

A minimal read-only identity check that can be run in an authorised Automation Account is:

powershell
# Illustrative connectivity test: no Sentinel modifications.
$ErrorActionPreference = 'Stop'

Connect-AzAccount -Identity | Out-Null
$context = Get-AzContext

if (-not $context) {
    throw 'Azure Automation managed identity sign-in did not establish a context.'
}

Write-Output "Managed identity authentication established."
Write-Output "Subscription context: $($context.Subscription.Name)"

Avoid printing subscription IDs, tokens or identity secrets in shared job transcripts. Confirm the actual target subscription and workspace through secured Automation variables or parameter input, not hard-coded customer identifiers.

Step 4 — Update eligible Content Hub solutions

The source guide's Update-ContentHub.ps1 uses PowerShell and REST APIs to find installed solutions and apply eligible updates. It exposes a preview-content option; consider whether preview solutions should be excluded by policy.

For each installed solution, log at least the resource reference, current/latest version, assessment result and final outcome. Do not repeatedly redeploy unchanged content. Where updating a solution could change connectors or workbook dependencies, use a maintenance window and a tested recovery plan.

Use the credited upstream source, pin the approved revision in your runbook inventory and review every update to it.

Step 5 — Compare templates and update eligible analytics rules

The second referenced script, Update-AnalyticsRules.ps1, checks enabled Scheduled analytics rules against their template versions. Review the upstream release notes for rule identity and mapping preservation before selecting a revision.

A production rule can contain deliberate changes to its KQL, scheduling, severity, alert grouping, suppression, entity mapping or custom details. Updating it from a newer template without review can erase those tuning decisions. The upstream guide provides options to skip tuned rules based on selected KQL text, but keyword exclusions alone are not a reliable general-purpose change-control mechanism.

Before enabling unattended updates in any environment, export the existing active rule definition and compare the candidate deployment at the property level. Exclude manually tuned or critical detections unless approved. Preserve the rule's identity and record any intentional modifications.

Step 6 — Schedule and validate both update jobs

Run the Content Hub updater before the analytics-rule updater, with enough separation for content deployment and API propagation. Choose the interval to suit your change-control process and update frequency rather than copying an arbitrary schedule; the historical schedule is not available, so do not infer one from the reference scripts.

A safe rollout test should cover:

ScenarioExpected treatment
No new Content Hub solution versionLeave package unchanged and report no action
New solution version availablePrepare approved update; record result and downstream dependencies
Active rule already matches its templateNo change; avoid extra deployments
New template for an untuned, eligible Scheduled ruleReview the diff and deploy only under approved policy
Active rule contains intentional local KQL/grouping modificationsExclude or require explicit review; preserve backup
API, RBAC or authentication failureReport error and halt the affected action
Repeated runDo not create duplicate rules or restart unnecessary updates

Capture the previous analytics-rule JSON before change. Test the output against known expected query results and confirm the rule stays enabled with the intended scheduling, suppression, entity mapping and alert grouping. Check deployment audit logs and runbook job output. Have a documented procedure to restore the last approved rule definition if a template update degrades detection coverage.

A separate approval gate for detection changes

The following original example is a proposed wrapper design, not part of the upstream updater and not recovered historical code. It classifies a candidate rule change before an operator permits deployment. Supply exported and normalised rule properties from the same active rule; a missing property requires review rather than being silently ignored.

powershell
function Get-DetectionChangeDecision {
    param(
        [Parameter(Mandatory)][hashtable]$Current,
        [Parameter(Mandatory)][hashtable]$Candidate
    )
    $protected = @('query','severity','queryFrequency',
        'queryPeriod','triggerOperator','triggerThreshold',
        'suppressionEnabled','suppressionDuration',
        'entityMappings','customDetails','eventGroupingSettings',
        'incidentConfiguration','enabled')
    $changed = foreach ($key in $protected) {
        if (-not $Current.ContainsKey($key) -or
            -not $Candidate.ContainsKey($key)) { $key; continue }
        $before = ConvertTo-Json -InputObject $Current[$key] -Depth 50 -Compress
        $after = ConvertTo-Json -InputObject $Candidate[$key] -Depth 50 -Compress
        if ($before -cne $after) { $key }
    }
    [pscustomobject]@{
        Decision = if (@($changed).Count -gt 0) {
            'ManualReview'
        } else { 'EligibleForFurtherValidation' }
        ChangedProperties = @($changed)
    }
}

This conservative example never deploys a rule. JSON ordering can cause false differences; canonicalise nested objects for production use. Check all remaining properties, active identity, template provenance and change authorisation separately. Treat any failed check as a hold. The snippet has not been executed against a live workspace.

Troubleshooting, guardrails and rollback

The benefit is not merely avoiding repetitive portal clicks: it is controlling detection drift across Content Hub solutions without undoing locally tuned detections. That requires two distinct checks—whether a solution changed, and whether an active rule should adopt the new template.

The main hazards to design for are unreviewed replacement of tuned KQL, unwanted changes to alert grouping or entity mappings, duplicate rule IDs, insufficient permissions and silent automation failures. A conservative deployment should start with version assessment and an export/diff stage, limit automatic writes to deliberately approved rules, and produce a human-readable outcome summary. The original deployment's exact script revisions, schedules and job logs are unavailable; the table above is a reproducible validation plan, not an invented job result.

This architecture remains useful even when an organisation chooses to require human approval before the final update step. Tracking available template versions and the reasons rules were skipped is itself valuable detection engineering work.

Sources and credit