Last active
June 1, 2020 18:18
-
-
Save dbarkol/d62be281331f8c92aa1ca00275486c96 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rgname={your-resource-group-name} | |
servicebus_uri={namespace-name}.servicebus.windows.net/{queue-name} | |
shared_access_key_name={your-shared-access-key-name} | |
shared_access_key={your-shared-access-key} | |
EXPIRY=${EXPIRY:=$((60 * 60 * 24))} | |
ENCODED_URI=$(echo -n $servicebus_uri | jq -s -R -r @uri) | |
TTL=$(($(date +%s) + $EXPIRY)) | |
UTF8_SIGNATURE=$(printf "%s\n%s" $ENCODED_URI $TTL | iconv -t utf8) | |
HASH=$(echo -n "$UTF8_SIGNATURE" | openssl sha256 -hmac $shared_access_key -binary | base64) | |
ENCODED_HASH=$(echo -n $HASH | jq -s -R -r @uri) | |
echo -n "SharedAccessSignature sr=$ENCODED_URI&sig=$ENCODED_HASH&se=$TTL&skn=$shared_access_key_name" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment