/// <summary> /// Migration clean up /// </summary> /// <returns></returns> static async Task UserMigrationCleanupAsync() { string appDirecotyPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string dataFilePath = Path.Combine(appDirecotyPath, Program.MigrationFile); // Check file existence if (!File.Exists(dataFilePath)) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"File '{dataFilePath}' not found"); Console.ResetColor(); return; } // Read the data file and convert to object LocalAccountsModel users = LocalAccountsModel.Parse(File.ReadAllText(dataFilePath)); // Create B2C graph client object B2CGraphClient b2CGraphClient = new B2CGraphClient(Program.Tenant, Program.ClientId, Program.ClientSecret); foreach (var item in users.Users) { Console.WriteLine($"Deleting user '{item.email}'"); await b2CGraphClient.DeleteAADUserBySignInNames(item.email); } }