[Support Guide] How to connect Azure DevOps repositories to Netlify

Hello friends! Below is a video demo & docs on how to connect Azure DevOps repositories to Netlify.

I hope you find this content useful!

Step 1. Initialize the Netlify site with the Netlify CLI

After installing the CLI, run the following command

netlify init --manual

This command will create a new site in Netlify and give you the ssh key you will need to plugin to your Azure DevOps account. That URL will look something like https://dev.azure.com/{your-user-name}/_usersSettings/keys. You can always grab this key again from https://app.netlify.com/sites/{your-site-slug}/settings/deploys#deploy-key

This netlify init --manual command will also give you back a deploy hook that looks like: https://api.netlify.com/hooks/{hookId}, this hook required a specific payload & is troublesome to work with in Azure DevOps, we can ignore this.

2. Create a new Netlify build hook.

Head into your newly minted Netlify site admin and create a new build hook.
Take this new build hook URL and plug it into your Azure DevOps repo under settings & service hooks (See docs on creating service hooks. The service hooks admin URL will look something like https://dev.azure.com/{user-name}/{repo-name}/_settings/serviceHooks

Change code & verify builds in Netlify

Great job so far. Now let’s change our code in Azure DevOps and verify that out webhook is triggering a build inside of Netlify!
Visit https://app.netlify.com/sites/{your-site-slug}/deploys to verify the code change has triggered a Netlify build & deploy.


Hi David,
Thanks for the useful content. I followed you suggested step to run “netlify init --manual” command and create a Netlify site, however, no SSH public key is presented after the site creation. Could you tell me if I miss anything?

Choose a unique site name (e.g. null-makes-great-sites.netlify.app) or leave it blank for a random name. You can update the site name later.
? Site name (optional): {mysite}
Site Created
Admin URL: https://app.netlify.com/sites/{mysite}
URL: https://{mysite}.netlify.app
Site ID: 401b9036-a0c9-4cfa-9b93-950ab0897aca
“{mysite}” site was created

To deploy to this site. Run your site build and then netlify deploy

Thanks in advance

Hi, @steve_wong. You can generate the SSH key here:


I also don’t know if the site is correctly linked to the repo. If the repo isn’t linked correctly, the key would be useless because we will never connect to the upstream repo.

I believe you can relink the repo using netlify link:

$ netlify link help
Link a local repo or project folder to an existing site on Netlify

  $ netlify link

  --auth=auth                    Netlify auth token
  --gitRemoteName=gitRemoteName  Name of Git remote to use. e.g. "origin"
  --id=id                        ID of site to link to
  --json                         Output return values as JSON
  --name=name                    Name of site to link to
  --silent                       Silence CLI output

If there are still issues after generating the key and linking the repo, please let us know.

This doesn’t work on netlify 2.55. Following the steps listed appears to link the Azure Repo to the Netlify site, but the tool doesn’t parse the repo url properly and the resulting repo URL is only the path portion of the actual URL.

For instance, if the git remote origin URI to your Azure Repo is https://myaccount@dev.azure.com/myaccount/Project/_git/MyRepo, the tool stores the URI as myaccount/Project/_git/MyRepo, resulting in the following error:

Failed during stage 'preparing repo': error checking for ref: fatal: 'myaccount/Project/_git/MyRepo' does not appear to be a git repository
fatal: Could not read from remote repository.

This probably happens because your repo is specified in that https format. It needs to be specified in the ssh format instead. Not sure what this looks like for MS, but for github it’s:


Is there something similar for the MS situation? (You don’t have to use it otherwise, but it is the only thing we can use, so you need to have the repo specified like that in your .git/config when you link with us!)

https is the default protocol for Azure Repos, and I have GitHub repos linked to my Netlify sites using an https URI. If Azure Repos git remotes must be in ssh format, this document should clearly specify that at the beginning. Since creating ssh keys is not a standard Windows/Visual Studio operation, a link to a document on how to do that for Windows users wouldn’t go amiss, either.

You do not in fact have your GitHub repos linked to your netlify sites using an https URI.

We always fetch with deploy keys using SSH.

Our UI links to your commit via HTTPS, and specifies the repo in that format in our UI, but we require it to be in ssh format to use.

Good suggestion on the docs! Mind writing that up for us? I don’t use Azure Devops or windows myself, and neither do any of my team so it is unlikely we’ll create more docs for this unofficial support ourselves :slight_smile: . I will edit the article to mention the requirement for ssh, once I confirm it is true with the fellow who wrote this post.

Hey @DavidWells that’s works for me, thank you :slight_smile:

1 Like

HI there @DavidWells , thank you for this guide, it has been very helpful. I have a question around connecting multiple sites to a single repo. I have a single repo in Azure Devops which is currently linked to a Netlify site. I would like to link the repo to another different Netlify site in the same account. When I run:
“netlify init --manual” the cli responds: “This site has been initialized”.

Is there a way I can init a new site in Netlify and link it to the same repo?

Thank you.

The site link is stored in a text file with the site API id stored there. The path to this file is .netlify/state.json relative to the base directory of the repo itself.

For example:

$ cat .netlify/state.json
	"siteId": "5092fde1-c045-4222-86f3-bef6d75b1575"

Because of this, a single local repo directory can only be linked to a single Netlify site.

Now, you can link a single repo to multiple Netlify sites. The limitation is that using netlify link in the local repo directory links that specific directory to that specific site (via the .netlify/state.json file).

So, one workaround is to make multiple clones of the same repo (each to a different directory) and then link the repo to different sites that way. Each clone of the repo would have a different .netlify/state.json. (Note, directory .netlify should be in .gitignore. We do not recommend tracking those files in Git.)

However, there is probably a better way of doing this. For example, are you making manual deploys to different sites from a single local repo?

If the answer is “yes”, I would recommend not linking at all. Instead, just pass the site id to the netlify CLI command directly in the command line itself, like so:

netlify deploy --prod -d publish --site="API-ID-GOES-HERE"

Replacing “API-ID-GOES-HERE” with the actual API ID for the site.

​Please let us know if there are questions about either solution or if neither will meet your requirements.

Thank you for the response. In answer to your question, I currently have a repo that has an env variable called country which has two possible values. Changing this will produce a different site in terms of content. This is the only thing that would change between the two sites.

Currently the site that is already linked is set to deploy from manual (triggers a build and deploy when a merge to master is complete in Azure Devops). The build uses the settings in the netlify.toml file and the env value of country=AUS.

We would like to replicate this same process but for the env value of country=NZ.

So what you’re saying is there’s a couple of options:

  1. Clone the repo and link to a new site, this seems straight forward but would just mean writing a process to keep the repos in sync I think.

  2. Deploy via the CLI. If we went with the second option, would the site files have to be built locally via cli command before deploying? (FYI, it’s a Gatsby site)

Thank you for your help

***Edit, I ended up following your advice and cloned the repo into a different directory and then followed the steps from the video again. All working as intended now.

there would only be one repo - you’d link it to two sites. Then in each site’s build settings, you’d set a variable specific to each country. You can specify the rest of the per-site settings in netlify.toml in the repo, if you don’t want to worry about keeping them in sync :slight_smile:

(cf https://docs.netlify.com/configure-builds/file-based-configuration/ for the format of netlify.toml)