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

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)

Azure repos doesn’t support git over ssh with LFS. Is there any way to link the repo with https?

Oh, wow, sorry to hear that. That would mean there is no way to use LFS there, then, I suppose.

Our Large Media service uses our own LFS service rather than your git provider’s, but it does have a fair number of caveats including not being able to link the same repo on two netlify sites and more: https://docs.netlify.com/large-media/requirements-and-limitations/#limitations

If none of those seem problematic to you, you could try using it since that should work around the missing feature at Azure Devops.

Hi I am coming from GitHub to Devops and was hoping there were some guidelines on how to setup hooks to build deploy previews and branch’s?

hi _Duncan, unfortunately, we don’t have any content for you on this topic at the moment! I’m sorry, I wish i had better news.

Hi everyone, I’m stuck following these instructions as every time I get to the last step configuring the Git SSH URL I get the following error:

The SSH URL of the remote git repo: git@ssh.dev.azure.com:v3/ignite-systems/Wintrix/ignite-portal
› Error: Failed updating site with repo information with error: Not Found

Anybody experience something similar? That URL is definitely valid and reachable as I git a git clone URL and it all works great.

Hey @GerardWilkinson,

Sorry to keep you waiting. Unfortunately, our first-hand support for GitHub, Gitlab and Bitbucket hasn’t quite extended to Azure! However, there are some handy guides out there with a couple of gotchas. Hopefully this helps and I look forward to hearing back from you!

1 Like

Hi David,

I have a question, I am able to do all the things that you instructed, using azure DevOps, however, I have a request could you also show us how to configure the deploy preview? basically, I want to deploy the pull request version as a preview

Thank you

hey richard, unfortunately, david left netlify some time ago! i will still leave your question open, but i am not sure who else might be able to assist, as azure questions are getting increasingly uncommon around these parts. if you make any progress, please do share it though!

Hi Richard,

Unfortunately, today, we don’t support Azure Devops the same way that we support our 3 first-class Git providers and, as such, DPs are unsupported.

We do appreciate the feedback and raising this with us allows us to share the insight with our product team! We’ll be sure to let you know if Azure Devops is supported as a first-class provider in future.

Hi everyone :wave: , thanks for your interest in using Netlify with Azure repos!

We’re pleased to announce that Netlify now natively supports Azure DevOps as a Git provider! While you can still connect an Azure repo to a site using netlify init --manual as described in this thread, you can instead connect a site directly in the Netlify app. In addition to automated builds and deploys, you can use deploy notifications, branch deploy contexts, and Deploy Previews with your sites connected to Azure DevOps.

You can find more details in the docs. Once you’ve had the chance to try out the new integration, please feel free to share your feedback. Happy coding!

1 Like