Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow case-insensitive segments in Azure Resource Ids #700

Merged
merged 5 commits into from
Feb 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions src/Query/AzureServiceBus/AzureClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,16 @@ public class AzureClient
public AzureClient(string resourceId, string serviceBusDomain, Action<string> log = null)
{
this.resourceId = resourceId;

this.log = log ?? new(msg => { });

var parts = resourceId.Split('/');
if (parts.Length != 9 || parts[0] != string.Empty || parts[1] != "subscriptions" || parts[3] != "resourceGroups" || parts[5] != "providers" || parts[6] != "Microsoft.ServiceBus" || parts[7] != "namespaces")
{
throw new Exception("The provided --resourceId value does not look like an Azure Service Bus resourceId. A correct value should take the form '/subscriptions/{GUID}/resourceGroups/{NAME}/providers/Microsoft.ServiceBus/namespaces/{NAME}'.");
}
var resourceIdentifier = ResourceIdentifier.Parse(resourceId);

ResourceGroup = resourceIdentifier.ResourceGroupName;

ResourceGroup = parts[4];
SubscriptionId = parts[2];
var name = parts[8];
SubscriptionId = resourceIdentifier.SubscriptionId;

FullyQualifiedNamespace = $"{name}.{serviceBusDomain}";
FullyQualifiedNamespace = $"{resourceIdentifier.Name}.{serviceBusDomain}";

connections = CreateCredentials()
.Select(c => new AuthenticatedClientSet(c, FullyQualifiedNamespace))
Expand Down