I’m deploying a node.js app to Azure Web Services using git from my local machine via: git push azure master
One of our npm packages is a private repo hosted on BitBucket. Without Azure having an SSH key to clone that repo, the deployment fails.
How can I add an SSH key to my Azure server that will get used during these deployment executions?
You’ll need to setup a deployment key on Bitbucket that you can provide to Azure to get the package from Bitbucket.
- Take the full deploy URL (such as
https://mysite.scm.azurewebsites.net/deploy), and replace /deploy
with /api/sshkey?ensurePublicKey=1. So it’ll look like
- Run curl on this URL, which returns an SSH public key. It’s returned
as a JSON string, so you’ll need to remove the quotes. It should
look like ssh-rsa AAAAB3NzaC1etc…
- Set this string as a ‘deploy
key’ on your GitHub/Bitbucket/GitLab repository.
Full source here