So I have an automation tool that uses c# to invoke a Powershell script that will use sqlpackage.exe to extract a database on a remote server into a .dacpac and save it into my file system.
We use asynchronous calls to the powershell process/pipeline to get the current result of the script execution and output them to the screen for the user. This tool has worked fine for ages but suddenly is stopping halfway through the extraction process and throwing the following error message "Error extracting database:Could not export schema and data from database.Can not access a closed Stream." At this point I have no idea what is causing the stream to get interupted and the extraction process to come to sudden halt.
Just wondering if anyone has experienced anything similar or if anyone can recommend some steps to debug this error?
Here is the portion of my script that is performing the extraction:
sqlpackage `
/action:extract `
/SourceConnectionString:"$endpoint" `
/TargetFile:"$dacPacFile" `
/p:ExtractAllTableData=True `
/p:ExtractReferencedServerScopedElements=False `
/p:IgnoreUserLoginMappings=True