Ways to re-reun failed appium tests on an Azure Pipeline with a Browserstack Cloud

Is anyone else trying this? I see a hacky way to do this in Azure that re-runs all the tests and through a Powershell script. I would prefer to use DotNet Test with an Argument. I know this is not quite as Appium related as it should eb but am interested if other people using Appium have any recommendations.

I use testNG with retry listener automatically retry failed test. Example e.g. https://qaautomation.expert/2022/07/19/how-to-retry-failed-tests-in-testng-iretryanalyzer/