Share via

an error Initialize-AzModule

Anonymous
2025-03-20T21:07:03.5666667+00:00
An error occurred in Initialize-AzModule
2025-03-20T20:53:52.4803440Z ##[error]The term 'Resolve-Error' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
2025-03-20T20:53:52.5982234Z ##[error]PowerShell exited with code '1'.
Azure DevOps

1 answer

Sort by: Most helpful
  1. Rajat Kapoor 0 Reputation points Microsoft Employee
    2026-01-29T10:44:35.9166667+00:00

    getting this error - An error occurred in Initialize-AzModule

    ##[error]Could not find the modules: 'Az.Accounts' with Version: ''. If the module was recently installed, retry after restarting the Azure Pipelines task agent.

    ##[error]PowerShell exited with code '1'.

    In this yml stage -

    ## Edge-Test-LAXr9a HC - Alert on Failure (Non-Release Stage)
    - stage: "Edge_Test_LAXr9a_HC_Alert"
      displayName: "LAXr9a Alert on Failure"
      dependsOn: Test_Edge_LAXr9a_HealthCheck
      condition: failed()
      jobs:
        - job: Send_Alert_To_Log_Analytics
          displayName: "Send Alert To Log Analytics"
          pool:
            type: windows
          variables:
            ob_outputDirectory: '$(Build.SourcesDirectory)\out'
          steps:
            - task: AzurePowerShell@5
              displayName: "Azure PowerShell script: Create Alert If Pipeline Fails"
              inputs:
                azureSubscription: "AFD-MSFT-Ops: Infrastructure Services"
                ScriptType: 'InlineScript'
                azurePowerShellVersion: 'OtherVersion'
                preferredAzurePowerShellVersion: '9.7.1'
                Inline: |
                  # PowerShell script to send alert to Log Analytics
                  # Az.Accounts is already available in AzurePowerShell task
                  # Define Key Vault and secrets
                  $KeyVaultName = "Pipeline-LAWSecret"
                  $LogAnalyticsWorkspaceIdSecretName = "LogAnalyticsWorkspaceID"
                  $LogAnalyticsSharedKeySecretName = "LogAnalyticsSharedKey"
                  # Retrieve secrets from Azure Key Vault
                  try {
                      $LogAnalyticsWorkspaceId = Get-AzKeyVaultSecret -VaultName $KeyVaultName -Name $LogAnalyticsWorkspaceIdSecretName -AsPlainText
                      $SharedKey = Get-AzKeyVaultSecret -VaultName $KeyVaultName -Name $LogAnalyticsSharedKeySecretName -AsPlainText
                      Write-Host "Successfully retrieved Log Analytics Workspace ID and Shared Key."
                  } catch {
                      Write-Host "Failed to retrieve secrets from Key Vault: $_"
                      exit 1
                  }
    ...
    ...
    

    Was this answer helpful?

    0 comments No comments

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.