This Action lets you send custom log to Azure Monitor Log Analytics workspace from a GitHub workflow.
The action requires following 2 secrets. Set the secret value on your github repository, Settings > Secrets
LA_WORKSPACE_ID
: get a value from Log Analytics workspace > Overview > Workspace IDLA_AGENT_KEY
: get a value from Log Analytics workspace > Agents management > Primary/Secondary key
- name: Send Log to Azure Monitor
uses: hoisjp/[email protected]
with:
workspace-id: ${{ secrets.LA_WORKSPACE_ID }}
agent-key: ${{ secrets.LA_AGENT_KEY }}
json-body: '{message: "Unit Test Finished.", youCanGiveAnyFieldName: true}'
You can query with this type name in KQL.
GitHubAction_CL
First, you'll need to have a reasonably modern version of
node
handy. This won't work with versions older than 9, for instance.
Install the dependencies
$ npm install
Lint, test and build the typescript and package it for distribution
$ npm run all
Run the tests ✔️
$ npm test
> [email protected] test
> jest
PASS __tests__/main.test.ts
...
Test Suites: N passed, N total
Tests: N passed, N total
Snapshots: 0 total
Time: 10 s
Ran all test suites.
Create .secrets
for GitHub Secrets values with replacing your actual secrets.
LA_WORKSPACE_ID=REPLACE_HERE
LA_AGENT_KEY=REPLACE_HERE
And run with act
command. See also https://github.com/nektos/act to install.
$ act -l
ID Stage Name
build 0 build
test 0 test
$ act -j build
...
[build-test/build] ✅ Success - npm run all
$ act -j test --secret-file .secrets
...
[build-test/test] ✅ Success - Azure Monitor Action
Actions are run from GitHub repos so we will checkin the packed dist folder.
Then run ncc and push the results:
$ npm run package
$ git add dist
$ git commit -a -m "prod dependencies"
$ git push origin releases/v1
Note: We recommend using the --license
option for ncc, which will create a license file for all of the production node modules used in your project.
Your action is now published! 🚀 See the versioning documentation