Skip to content

Run module with log analytics #170

Run module with log analytics

Run module with log analytics #170

# Run on manual trigger and every day at 6:00 AM UTC
on:
workflow_dispatch:
schedule:
- cron: '0 6 * * *'
name: Run module with log analytics
jobs:
run-psrule-monitor:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
name: Checkout
- name: Install PSRule
run: |
# Install-Module -Name PSRule -Force -Scope CurrentUser -SkipPublisherCheck
Install-Module -Name PSRule.Monitor -Force -Scope CurrentUser -SkipPublisherCheck
shell: pwsh
- name: Run PSRule
run: |
Import-Module PSRule
Import-Module PSRule.Monitor
Import-Module ./src/PSRule.Rules.AzureDevOps/PSRule.Rules.AzureDevOps.psd1 -Force
Connect-AzDevOps -Organization ${{ secrets.ADO_ORGANIZATION }} -PAT ${{ secrets.ADO_PAT }}
New-Item -Path ./data -ItemType Directory -Force
Export-AzDevOpsOrganizationRuleData -OutputPath ./data
$result = Invoke-PSRule -InputPath ./data/ `
-Module "PSRule.Rules.AzureDevOps","PSRule.Monitor" `
-Format Detect -Culture en
$result | Send-PSRuleMonitorRecord -WorkspaceId $Env:PSRULE_CONFIGURATION_MONITOR_WORKSPACE_ID `
-SharedKey $Env:PSRULE_CONFIGURATION_MONITOR_WORKSPACE_KEY -LogName RjbTest
shell: pwsh
env:
PSRULE_CONFIGURATION_MONITOR_WORKSPACE_ID: ${{ secrets.PSRULE_CONFIGURATION_MONITOR_WORKSPACE_ID }}
PSRULE_CONFIGURATION_MONITOR_WORKSPACE_KEY: ${{ secrets.PSRULE_CONFIGURATION_MONITOR_WORKSPACE_KEY }}
PSRULE_CONVENTION_INCLUDE: "Monitor.LogAnalytics.Import"