Skip to content

Instantly share code, notes, and snippets.

@swordfish6975
Created September 14, 2023 02:11
Show Gist options
  • Select an option

  • Save swordfish6975/d1caeb907ba0054d2bc1ca0e40d300de to your computer and use it in GitHub Desktop.

Select an option

Save swordfish6975/d1caeb907ba0054d2bc1ca0e40d300de to your computer and use it in GitHub Desktop.
Extract the Function App Settings your looking for from all of Azure (that you have access to)
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.AppService;
using Newtonsoft.Json;
namespace AzureSettingsFinder
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Started...");
var target = args[0];
ArmClient client = new(new DefaultAzureCredential());
foreach (var subs in client.GetSubscriptions())
{
foreach (var resGroups in subs.GetResourceGroups())
{
foreach (var website in resGroups.GetWebSites())
{
try
{
var setttings = website.GetApplicationSettings();
var props = setttings.Value.Properties.Where(x => x.Key.Contains(target) || x.Value.Contains(target));
foreach (var prop in props)
{
Console.WriteLine($"Name: {website.Data.Name} Target: {target} Key: {prop.Key} Value: {prop.Value}");
}
}
catch (Exception ex)
{
// Console.WriteLine($"ERROR: {website.Data.Name} {ex.Message} | {ex.InnerException}");
}
}
}
}
Console.WriteLine("Done.");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment