44using System . CommandLine ;
55using System . Text . Json ;
66using Microsoft . Extensions . Logging ;
7+ using Microsoft . Agents . A365 . DevTools . Cli . Services . Helpers ;
78using Microsoft . Agents . A365 . DevTools . Cli . Services ;
89using Microsoft . Agents . A365 . DevTools . Cli . Models ;
910
@@ -145,11 +146,11 @@ private static Command CreateAzureCleanupCommand(
145146 logger . LogInformation ( "" ) ;
146147 logger . LogInformation ( "Azure Cleanup Preview:" ) ;
147148 logger . LogInformation ( "=========================" ) ;
148- logger . LogInformation ( " • Web App: {WebAppName}" , config . WebAppName ) ;
149- logger . LogInformation ( " • App Service Plan: {PlanName}" , config . AppServicePlanName ) ;
149+ logger . LogInformation ( " Web App: {WebAppName}" , config . WebAppName ) ;
150+ logger . LogInformation ( " App Service Plan: {PlanName}" , config . AppServicePlanName ) ;
150151 if ( ! string . IsNullOrEmpty ( config . BotId ) )
151- logger . LogInformation ( " • Azure Bot: {BotId}" , config . BotId ) ;
152- logger . LogInformation ( " • Resource Group: {ResourceGroup}" , config . ResourceGroup ) ;
152+ logger . LogInformation ( " Azure Bot: {BotId}" , config . BotId ) ;
153+ logger . LogInformation ( " Resource Group: {ResourceGroup}" , config . ResourceGroup ) ;
153154 logger . LogInformation ( "" ) ;
154155
155156 Console . Write ( "Continue with Azure cleanup? (y/N): " ) ;
@@ -173,22 +174,21 @@ private static Command CreateAzureCleanupCommand(
173174 logger . LogInformation ( "Deleting messaging endpoint registration..." ) ;
174175 if ( string . IsNullOrEmpty ( config . AgentBlueprintId ) )
175176 {
176- logger . LogError ( "Agent Blueprint ID not found." ) ;
177- throw new InvalidOperationException ( "Agent Blueprint ID is required for deleting endpoint registration" ) ;
177+ logger . LogError ( "Agent Blueprint ID not found. Agent Blueprint ID is required for deleting endpoint registration." ) ;
178178 }
179+ else
180+ {
181+ var endpointName = EndpointHelper . GetEndpointName ( config . BotName ) ;
179182
180- var endpointName = config . BotName . Length > 42
181- ? config . BotName . Substring ( 0 , 42 )
182- : config . BotName ;
183+ var endpointRegistered = await botConfigurator . DeleteEndpointWithAgentBlueprintAsync (
184+ endpointName ,
185+ config . Location ,
186+ config . AgentBlueprintId ) ;
183187
184- var endpointRegistered = await botConfigurator . DeleteEndpointWithAgentBlueprintAsync (
185- config . BotName ,
186- config . Location ,
187- config . AgentBlueprintId ) ;
188-
189- if ( ! endpointRegistered )
190- {
191- logger . LogWarning ( "Failed to delete blueprint messaging endpoint" ) ;
188+ if ( ! endpointRegistered )
189+ {
190+ logger . LogWarning ( "Failed to delete blueprint messaging endpoint" ) ;
191+ }
192192 }
193193 }
194194
@@ -252,10 +252,10 @@ private static Command CreateInstanceCleanupCommand(
252252 logger . LogInformation ( "Will delete the following resources:" ) ;
253253
254254 if ( ! string . IsNullOrEmpty ( config . AgenticAppId ) )
255- logger . LogInformation ( " • Agent Identity Application: {IdentityId}" , config . AgenticAppId ) ;
255+ logger . LogInformation ( " Agent Identity Application: {IdentityId}" , config . AgenticAppId ) ;
256256 if ( ! string . IsNullOrEmpty ( config . AgenticUserId ) )
257- logger . LogInformation ( " • Agent User: {UserId}" , config . AgenticUserId ) ;
258- logger . LogInformation ( " • Generated configuration file" ) ;
257+ logger . LogInformation ( " Agent User: {UserId}" , config . AgenticUserId ) ;
258+ logger . LogInformation ( " Generated configuration file" ) ;
259259 logger . LogInformation ( "" ) ;
260260
261261 Console . Write ( "Continue with instance cleanup? (y/N): " ) ;
@@ -356,18 +356,18 @@ private static async Task ExecuteAllCleanupAsync(
356356 logger . LogInformation ( "============================" ) ;
357357 logger . LogInformation ( "WARNING: ALL RESOURCES WILL BE DELETED:" ) ;
358358 if ( ! string . IsNullOrEmpty ( config . AgentBlueprintId ) )
359- logger . LogInformation ( " • Blueprint Application: {BlueprintId}" , config . AgentBlueprintId ) ;
359+ logger . LogInformation ( " Blueprint Application: {BlueprintId}" , config . AgentBlueprintId ) ;
360360 if ( ! string . IsNullOrEmpty ( config . AgenticAppId ) )
361- logger . LogInformation ( " • Agent Identity Application: {IdentityId}" , config . AgenticAppId ) ;
361+ logger . LogInformation ( " Agent Identity Application: {IdentityId}" , config . AgenticAppId ) ;
362362 if ( ! string . IsNullOrEmpty ( config . AgenticUserId ) )
363- logger . LogInformation ( " • Agent User: {UserId}" , config . AgenticUserId ) ;
363+ logger . LogInformation ( " Agent User: {UserId}" , config . AgenticUserId ) ;
364364 if ( ! string . IsNullOrEmpty ( config . WebAppName ) )
365- logger . LogInformation ( " • Web App: {WebAppName}" , config . WebAppName ) ;
365+ logger . LogInformation ( " Web App: {WebAppName}" , config . WebAppName ) ;
366366 if ( ! string . IsNullOrEmpty ( config . AppServicePlanName ) )
367- logger . LogInformation ( " • App Service Plan: {PlanName}" , config . AppServicePlanName ) ;
367+ logger . LogInformation ( " App Service Plan: {PlanName}" , config . AppServicePlanName ) ;
368368 if ( ! string . IsNullOrEmpty ( config . BotName ) )
369- logger . LogInformation ( " • Azure Messaging Endpoint: {BotName}" , config . BotName ) ;
370- logger . LogInformation ( " • Generated configuration file" ) ;
369+ logger . LogInformation ( " Azure Messaging Endpoint: {BotName}" , config . BotName ) ;
370+ logger . LogInformation ( " Generated configuration file" ) ;
371371 logger . LogInformation ( "" ) ;
372372
373373 Console . Write ( "Are you sure you want to DELETE ALL resources? (y/N): " ) ;
@@ -423,18 +423,21 @@ private static async Task ExecuteAllCleanupAsync(
423423 logger . LogInformation ( "Deleting messaging endpoint registration..." ) ;
424424 if ( string . IsNullOrEmpty ( config . AgentBlueprintId ) )
425425 {
426- logger . LogError ( "Agent Blueprint ID not found." ) ;
427- throw new InvalidOperationException ( "Agent Blueprint ID is required for deleting endpoint registration" ) ;
426+ logger . LogError ( "Agent Blueprint ID not found. Agent Blueprint ID is required for deleting endpoint registration." ) ;
428427 }
429-
430- var endpointRegistered = await botConfigurator . DeleteEndpointWithAgentBlueprintAsync (
431- config . BotName ,
432- config . Location ,
433- config . AgentBlueprintId ) ;
434-
435- if ( ! endpointRegistered )
428+ else
436429 {
437- logger . LogWarning ( "Failed to delete blueprint messaging endpoint" ) ;
430+ var endpointName = EndpointHelper . GetEndpointName ( config . BotName ) ;
431+
432+ var endpointRegistered = await botConfigurator . DeleteEndpointWithAgentBlueprintAsync (
433+ endpointName ,
434+ config . Location ,
435+ config . AgentBlueprintId ) ;
436+
437+ if ( ! endpointRegistered )
438+ {
439+ logger . LogWarning ( "Failed to delete blueprint messaging endpoint" ) ;
440+ }
438441 }
439442 }
440443
0 commit comments