Search code examples
c#sql-serverssassql-server-2016ssas-tabular

SSAS Tabular AMO - how to know when a requested refresh is complete


The partition class in the tabular AMO library has a method for refreshing the partition (RequestRefresh). I can use the AMO library to fire this off, however this method appears to be asynchronous and I cannot find a way of monitoring this request to know when the processing has completed (either refreshed or failed).

The partition class does have a "State" property, but in practice, this always appears to report as ready, even during processing or after a failure in refreshing the data that's caused no data to be written into the partition.

I need to be able to programatically refresh my cube partitions, but have tasks that I need to schedule after the build has completed, I could watch the refresh time, but that feels like the wrong way to do this and any failed attempts do not appear to change this value (therefore requiring some form of timeout or other method for detecting failed refreshes).


Solution

  • Please add the following line after RequestRefresh. SaveChanges is synchronous and the refresh operation isn't actually executed until SaveChanges is run:

    partition.RequestRefresh(RefreshType.Full);
    db.Model.SaveChanges();