Skip to content

Instantly share code, notes, and snippets.

@cicorias
Created March 10, 2021 14:40
Show Gist options
  • Save cicorias/36e9592a5d796fd094efe7fdc59d75a8 to your computer and use it in GitHub Desktop.
Save cicorias/36e9592a5d796fd094efe7fdc59d75a8 to your computer and use it in GitHub Desktop.
retrieving event grid key and topic stuff
#!/usr/bin/env bash
set -euxo pipefail
EG_ID=$1
KEY="key1"
endpoint=$(az eventgrid topic show --ids $EG_ID --query endpoint | sed -e 's/^"//' -e 's/"$//')
eg_name=$(az eventgrid topic show --ids $EG_ID --query name | sed -e 's/^"//' -e 's/"$//')
eg_group=$(az eventgrid topic show --ids $EG_ID --query resourceGroup | sed -e 's/^"//' -e 's/"$//')
echo "using endpoint: ${endpoint} and name ${eg_name}"
if [[ -z "$endpoint" ]] || [[ -z "$eg_name" ]]
then
echo "Empty endpoint or name"
echo "##vso[task.logissue type=error]event grid topic endpoint or key not found"
exit 1
fi
eg_key=$(az eventgrid topic key list --resource-group $eg_group --name $eg_name --query $KEY | sed -e 's/^"//' -e 's/"$//')
echo "##vso[task.setvariable variable=faulttopichostname;]$endpoint"
echo "##vso[task.setvariable variable=faulttopickey; issecret=true]$eg_key"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment