using System.Text.RegularExpressions;
using System.Collections.Generic;
public static void Main()
string path = "somerandom";
var m = Regex.Match(path.ToLower(), @"subscriptions\/(.*?)\/");
string sub = m.Groups[1].Value;
var AllowedTestSubscriptions = "8ee49137-b1a2-4c6f-9e7f-6fe62eaa238a,ef90e930-9d7f-4a60-8a99-748e0eea69de";
List<string> allowedApiPaths = new List<string>(new string[] { "healthping", "dependencyCheck", "devops", "deploy" });
if (m.Length != 2 && !allowedApiPaths.Any(s => path.Contains(s, StringComparison.OrdinalIgnoreCase)))
Console.WriteLine($"Unauthorized does not have permission to this API {path}");
else if (AllowedTestSubscriptions != null && !string.IsNullOrWhiteSpace(sub) && !AllowedTestSubscriptions.Split(',').Contains(sub, StringComparer.OrdinalIgnoreCase))
Console.WriteLine("Unauthorized does not have permission to subscription");
Console.WriteLine($"{path} is allowed");