Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,7 @@ public async Task<EndpointRegistrationResult> CreateEndpointWithAgentBlueprintAs
}
_logger.LogInformation("Successfully acquired access token");

// Normalize location: Remove spaces and convert to lowercase (e.g., "Canada Central" -> "canadacentral")
// Azure APIs require the API-friendly location name format
// TODO: Consider using `az account list-locations` for robust display name → programmatic name mapping
// See: https://learn.microsoft.com/en-us/cli/azure/account?view=azure-cli-latest#az-account-list-locations
// Current approach works for existing regions but may need updates for new region naming patterns
var normalizedLocation = location.Replace(" ", "").ToLowerInvariant();
var normalizedLocation = NormalizeLocation(location);
var createEndpointBody = new JsonObject
{
["AzureBotServiceInstanceName"] = endpointName,
Expand Down Expand Up @@ -260,23 +255,24 @@ public async Task<bool> DeleteEndpointWithAgentBlueprintAsync(
}
_logger.LogInformation("Successfully acquired access token");

var createEndpointBody = new JsonObject
var normalizedLocation = NormalizeLocation(location);
var deleteEndpointBody = new JsonObject
{
["AzureBotServiceInstanceName"] = endpointName,
["AppId"] = agentBlueprintId,
["TenantId"] = tenantId,
["Location"] = location,
["Location"] = normalizedLocation,
["Environment"] = EndpointHelper.GetDeploymentEnvironment(config.Environment),
["ClusterCategory"] = EndpointHelper.GetClusterCategory(config.Environment)
};
// Use helper to create authenticated HTTP client
using var httpClient = Services.Internal.HttpClientFactory.CreateAuthenticatedClient(authToken);

// Call the endpoint
_logger.LogInformation("Making request to delete endpoint (Location: {Location}).", location);
_logger.LogInformation("Making request to delete endpoint (Location: {Location}).", normalizedLocation);

using var request = new HttpRequestMessage(HttpMethod.Delete, deleteEndpointUrl);
request.Content = new StringContent(createEndpointBody.ToJsonString(), System.Text.Encoding.UTF8, "application/json");
request.Content = new StringContent(deleteEndpointBody.ToJsonString(), System.Text.Encoding.UTF8, "application/json");
var response = await httpClient.SendAsync(request);


Expand Down Expand Up @@ -364,4 +360,14 @@ public async Task<bool> DeleteEndpointWithAgentBlueprintAsync(
return false;
}
}

private string NormalizeLocation(string location)
{
// Normalize location: Remove spaces and convert to lowercase (e.g., "Canada Central" -> "canadacentral")
// Azure APIs require the API-friendly location name format
// TODO: Consider using `az account list-locations` for robust display name → programmatic name mapping
// See: https://learn.microsoft.com/en-us/cli/azure/account?view=azure-cli-latest#az-account-list-locations
// Current approach works for existing regions but may need updates for new region naming patterns
return location.Replace(" ", "").ToLowerInvariant();
}
}