diff --git a/src/Microsoft.Agents.A365.DevTools.Cli/Services/BotConfigurator.cs b/src/Microsoft.Agents.A365.DevTools.Cli/Services/BotConfigurator.cs index cedb137d..7af3cfb7 100644 --- a/src/Microsoft.Agents.A365.DevTools.Cli/Services/BotConfigurator.cs +++ b/src/Microsoft.Agents.A365.DevTools.Cli/Services/BotConfigurator.cs @@ -101,12 +101,7 @@ public async Task 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, @@ -260,12 +255,13 @@ public async Task 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) }; @@ -273,10 +269,10 @@ public async Task DeleteEndpointWithAgentBlueprintAsync( 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); @@ -364,4 +360,14 @@ public async Task 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(); + } }