-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Azure/azure-cli-extensions
#3526Labels
Milestone
Description
az feedbackauto-generates most of the information requested below, as of CLI version 2.0.62
Describe the bug
When we will run command from GitHub Actions az monitor scheduled-query list --debug --subscription ${{ env.SUBSCRIPTION}} -g ${{ env.RESOURCEGROUP }} it will randomally fail because of error message:
msrest.exceptions.DeserializationError: Cannot deserialize as [Action] an object of type <class 'dict'>
To Reproduce
You can run this command via GitHub Actions from GitHub runner ubuntu-latest and it will randomly happened.
Expected behavior
It will list all query alerts from specified subscription and resource group
Environment summary
It's GitHub Action which is set up by this workflow file:
name: audit_alerts
on:
workflow_dispatch:
jobs:
# JOB to run all deployments
fetch:
runs-on: ubuntu-latest
outputs:
alerts: ${{ steps.getlist.outputs.alerts }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install jq
run: sudo apt-get install jq
- name: Install yq
run: |
sudo apt install snapd
sudo snap install yq
- name: Get List
id: getlist
run: |
jsonlist=$(yq eval "keys" file-filters.yml --tojson)
echo "::set-output name=alerts::$(echo $jsonlist)"
- name: Print output
run: echo ${{ steps.getlist.outputs.alerts }}
- name: Print output fromJson
run: echo ${{ fromJson(steps.getlist.outputs.alerts) }}
audit:
needs: fetch
strategy:
fail-fast: false
matrix:
alerts: ${{ fromJSON(needs.fetch.outputs.alerts) }}
runs-on: ubuntu-latest
env:
version: '1.0.0'
AZURE_STORAGE_CONNECTION_STRING: 'FileEndpoint=https://ncrsaassharedtemplates.file.core.windows.net/;SharedAccessSignature=sv=2019-10-10&ss=bfqt&srt=sco&sp=rwlacupx&se=2030-06-19T17:18:27Z&st=2020-06-19T09:18:27Z&spr=https&sig=oJEEWbshPqHXT4KHpeo62c726%2FZ%2FcUqKRU6KBe3yr78%3D'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install jq
run: sudo apt-get install jq
- name: Install yq
run: |
sudo apt install snapd
sudo snap install yq
- name: Install jsonlint
run: sudo apt-get install python3-demjson
- name: Set variables
run: |
echo $MATRIX_CONTEXT
alerts=$(echo $MATRIX_CONTEXT | jq -r '.alerts')
echo "PRODUCT=$(cut -d'_' -f1 <<<"$alerts")" >> $GITHUB_ENV
echo "ENVKEY=$(cut -d'_' -f2 <<<"$alerts")" >> $GITHUB_ENV
echo "LEVEL=$(cut -d'_' -f3 <<<"$alerts")" >> $GITHUB_ENV
echo "COMPONENT=$(cut -d'_' -f4 <<<"$alerts")" >> $GITHUB_ENV
echo "RESOURCEGROUP=$(yq eval .$alerts.[].resourcegroup file-filters.yml | grep -v '^null$')" >> $GITHUB_ENV
echo "SUBSCRIPTION_NAME=$(yq eval .$alerts.[].subscription file-filters.yml | grep -v '^null$')" >> $GITHUB_ENV
env:
MATRIX_CONTEXT: ${{ toJSON(matrix) }}
- name: Lint Json files
run: |
for file in ${{ env.PRODUCT }}/${{ env.ENVKEY }}/${{ env.LEVEL }}/${{ env.COMPONENT }}/alerts/*.json ; do jsonlint ${file} ; done
for file in ${{ env.PRODUCT }}/${{ env.ENVKEY }}/${{ env.LEVEL }}/${{ env.COMPONENT }}/*.json ; do jsonlint ${file} ; done
- name: AZ login
run: az login --service-principal -u ${{ secrets.AZ_AD_TERRAFORM_DEPLOYMENT_APP_ID }} -p ${{ secrets.AZ_AD_TERRAFORM_DEPLOYMENT_CLIENT_SECRET }} --tenant ${{ secrets.AZ_AD_TERRAFORM_DEPLOYMENT_TENANT_ID }}
- name: Get Subscription ID
run: echo "SUBSCRIPTION=$(az account show --subscription "${{ env.SUBSCRIPTION_NAME}}" | jq -r '.id')" >> $GITHUB_ENV
- name: Azure alerts audit
run: |
az config set extension.use_dynamic_install=yes_without_prompt
az monitor scheduled-query list --debug --subscription ${{ env.SUBSCRIPTION}} -g ${{ env.RESOURCEGROUP }}
Reactions are currently unavailable