I have Variable Groups set for my Test-Demo-Main environments and I have so many variables in it. so before going for each deployment I need to compare each with each environment. Now I am checking the feasibility to automate this process with a console application. Could you please share your idea/thoughts on how can I get all the variables from each environment and compare with other env.
you can use the SDK to do these operations;
libs:
example to get variables from Group:
Uri _uri = new Uri("https://dev.azure.com/{your org}/");
VssBasicCredential loginCred = new VssBasicCredential("user", "PAT");
VssConnection vssConnection = new VssConnection(_uri, loginCred);
await vssConnection.ConnectAsync();
var taskagent = vssConnection.GetClient<TaskAgentHttpClient>();
var var_env_1 = (await c.GetVariableGroupAsync("projectname", 1)).Variables;
var var_env_2 = (await c.GetVariableGroupAsync("projectname", 2)).Variables;
var var_env_3 = (await c.GetVariableGroupAsync("projectname", 3)).Variables;
// 1,2,3 = idgroup, YOU CAN GET THE URL (variableGroupId) WHEN ACCESSING THE GROUP IN AZURE DEVOPS
// LOGIC TO COMPARE
refs:
https://github.com/microsoft/azure-devops-dotnet-samples/tree/main/ClientLibrary/Samples