Skip to content

Instantly share code, notes, and snippets.

@GBSmulders
Created November 7, 2018 11:20
Show Gist options
  • Save GBSmulders/f5ce90e9a0846ac2fe3b80d0258e540e to your computer and use it in GitHub Desktop.
Save GBSmulders/f5ce90e9a0846ac2fe3b80d0258e540e to your computer and use it in GitHub Desktop.
#!/bin/bash
appName=appName
resourceGroup=recourcegroup
key=devKey
value=superDuperSecret
jsonString='{"name":"'"${key}"'","value":"'"$value"'"}'
userName=$(az webapp deployment list-publishing-profiles -n ${appName} -g ${resourceGroup} --query "[?publishMethod=='MSDeploy'].userName" --output tsv)
userPassword=$(az webapp deployment list-publishing-profiles -n ${appName} -g ${resourceGroup} --query "[?publishMethod=='MSDeploy'].userPWD" --output tsv)
bearerToken=$(curl -u ${userName}:${userPassword} -sb -X GET https://${appName}.scm.azurewebsites.net/api/functions/admin/token | sed 's/.\(.*\)/\1/' | sed 's/\(.*\)./\1/')
curl -sb -X PUT -H "Authorization: Bearer ${bearerToken}" -H "Content-Type: application/json" -d $jsonString https://${appName}.azurewebsites.net/admin/host/keys/${key}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment