One of the most annoying issues with on prem installation (LBD) is when the deployment fails and one of the nastiest bugs is when it happens during a cleanup and requires some surgical removal as retrying results in more failures (warning this fix is not for the faint of heart (at least I don't like deleting apps inside of service fabric manually)).
Connect to the service fabric cluster with the D365FOLBDAdmin module config or manually with the Connect-ServiceFabric.
How I connect to the service fabric cluster with the D365FOLBDAdmin tool is below (Note: you will need to have the Service Fabric Certificate installed on the machine you are running this on)
Run below script which will clean up the apps.
Go to the WP folder inside of the Agent Share and remove the specific environments folder (if you are concerned you can always just move the folder outside of the WP folder).
Below script will delete the folder (can be done manually if you are more inclined)
Once executed login to LifeCycle Services (LCS) and hit retry on the deployment. Note this will take a bit longer but should go past the cleanup portion of the deployment scripts.
Still don't have the D365FOLBDAdmin module???
Get the latest version in below locations: