Share via

Azure Automation Runbook jobs randomly failing with error "The decryption operation failed, see inner exception."

REAutomation 0 Reputation points
2026-03-26T12:34:48.42+00:00

Powershell automation jobs are randomly Failing with an exception "The decryption operation failed, see inner exception". No way to gather any details about what the inner exception is. Details below.

Fails in azure when starting jobs manually or queued via schedule. PS 7.2 runtime environment, fails on azure, fails on hybrid worker. Created a PS 7.4 environment with newest modules and also getting the same random failures. Same input parameters sometimes fail, sometimes execute. Some jobs fail with no parameters even required, just starting -> failed. Nothing in logs of course, as the execution failed before start with the only message in the Exception tab is "The decryption operation failed, see inner exception". When I dig further into the Azure Automation account logs I don't see any details relating to this issue. I am getting some delayed queue jobs in my automation account as well, not sure if those are related.

Thanks for any help or guidance.

Azure Automation
Azure Automation

An Azure service that is used to automate, configure, and install updates across hybrid environments.


1 answer

Sort by: Most helpful
  1. Bharath Y P 7,080 Reputation points Microsoft External Staff Moderator
    2026-03-27T12:41:53.2866667+00:00

    It seems the failure is not caused by your runbook code, authentication logic, or managed identity. The error occurs before PowerShell is initialized. Connect-AzAccount -Identity and Connect-MgGraph -Identity do not decrypt Automation assets.

    Azure Automation job execution has two phases: service‑side and customer‑side.

    service‑side: Job metadata and parameters are loaded, Automation account assets are decrypted and Worker slot is allocated. Your failure occurs here

    If this phase fails:

    • No PowerShell host is created
    • No runbook code runs
    • No logs or streams are generated
    • Only a generic .NET exception is shown

    Runbook execution (customer‑side):

    • PowerShell starts
    • Connect-AzAccount / Connect-MgGraph execute
    • Your email logic runs

    It seems you never reach this phase, Because managed identity authentication does not use stored secrets, it is not involved in Automation encryption. If auth were the issue, you would see a PowerShell error stream which you do not.

    The email runbook fails more often only because it runs more frequently, increasing the chance of hitting an unhealthy backend instance.

    Delayed/queued jobs further confirm Automation backend instability, not script problems.

     What you can try now:

    Remove legacy Connect-AzAccount -Identity: The command is not required for Graph email functionality. Removing it prevents token request collisions at job start.

    __Test a minimal auth runbook:__Create a runbook that does only Managed Identity token acquisition

    Connect-MgGraph -Identity

    • Run this repeatedly on the same schedule/parallelism as your production email script.
    • Purpose: simulate the failure condition without other variables.
    • If failures appear here, it confirms token acquisition collisions are the root cause.

    Reduce concurrency / staggering schedules: For high-frequency jobs, consider:

    • Staggering start times across multiple workers.
    • Ensuring jobs do not overlap.
    • Introducing short random delays at job start if possible.

    This mitigates token contention at the Automation platform level.

    Monitor job queue delays: Use this as a signal of token pressure:

    Automation Account > Jobs > filter status = Queued

    • Long queues in your every-5-minute job indicate platform token pressure.
    • This is expected if multiple -Identity calls occur concurrently.

    Diagnostic Logging: You can keep JobLogs enabled.

    • Don’t expect inner exception details; the failure occurs before script execution, so logs are limited.
    • Still, logs confirm which jobs fail and under what schedule, helping with frequency adjustments.

    This might be intermittent Managed Identity token acquisition failures during job initialization under high-frequency or concurrent runs, leading to payload decryption errors.

    We have reached out to you in Private messages, could you please take a look into it? Thanks


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.