.net – How to prevent SSDT/DACPAC publish with DropObjectsNotInSource=True from dropping Azure Functions az_func runtime tables


I’m deploying a SQL Server/Azure SQL database using an SSDT .sqlproj (DACPAC) and SqlPackage.exe (DacFx publish). For local dev we require DropObjectsNotInSource=True so schema drift/renames are cleaned up automatically when running the solution (F5 triggers a PowerShell script that runs SqlPackage /Action:Publish).

Problem: Azure Functions (SQL triggers / runtime integration) creates and manages objects in a schema called az_func, e.g.:

Those objects are not in our SSDT project. When we publish with DropObjectsNotInSource=True, DacFx includes drop statements for az_func objects because they’re “not in source”. This breaks running Functions and loses the runtime state (the runtime recreates the schema later, but state/data is lost).

What I’ve tried:

  • Pre/post-deployment scripts: doesn’t help, because drops happen before post-deploy runs.

  • DoNotDropObjectTypes=Schema: not valid / doesn’t solve dropping tables anyway.

  • Custom tool that backs up az_func then restores it: works but feels brittle/overengineered (and can race if functions are active).

What I’m looking for:

  • Best practice way to keep DropObjectsNotInSource=True for our own schemas, but ensure nothing in schema az_func is dropped or altered during publish — including runtime tables with random suffixes (i don’t know the names ahead of time).

Questions:

  1. Is there a supported way in DacFx/SqlPackage to exclude a schema (or object set) from “drop not in source”?

  2. If not, is the right approach a DacFx deployment contributor / plan modifier that filters out any deployment plan steps touching schema az_func? If yes, can someone show a minimal example and how to wire it up to SqlPackage (properties/arguments)?

  3. Is using contributors viable (yes or no) i.e. DropObjectsNotInSource=True, with Azure SQL / Functions runtime objects created dynamically

(If it matters: local dev workflow is SqlPackage.exe /Action:Publish /SourceFile:*.dacpac /TargetConnectionString:... /p:DropObjectsNotInSource=True and we want the same approach to work in Azure DevOps too.)

Thanks in advance

Leave a Reply

Your email address will not be published. Required fields are marked *