Events
Power BI DataViz World Championships
Feb 14, 4 PM - Mar 31, 4 PM
With 4 chances to enter, you could win a conference package and make it to the LIVE Grand Finale in Las Vegas
Learn moreThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
This article provides a few Visual Studio app examples for comparing semantic model properties when Power BI semantic model scale-out is enabled.
The syncStatus
REST API shows if the read-write semantic model and read-only replicas are in sync. You can also use the Tabular Object Model (TOM) to build a custom application that connects to both semantic models and compares timestamps, metadata, and query results between them.
Use the code below to build an app that checks the LastUpdate, LastProcessed and LastSchemaUpdate properties of your semantic models. Before the app performs the checks, it needs to call the Refresh()
method, to get the replica's metadata.
Replace <WorkspaceUrl>
with your workspace's URL, and <Semantic modelName>
with your semantic model's name.
string workspaceUrl = "<WorkspaceUrl>"; // Replace <WorkspaceUrl> with the URL of your workspace
string datasetName = "<Semantic modelName>"; // Replace <Semantic modelName> with the name of your semantic model
using (var workspace_readwrite = new Microsoft.AnalysisServices.Tabular.Server())
using (var workspace_readonly = new Microsoft.AnalysisServices.Tabular.Server())
{
workspace_readwrite.Connect(workspaceUrl + "?readwrite");
workspace_readonly.Connect(workspaceUrl + "?readonly");
var datasetRW = workspace_readwrite.Databases.FindByName(semantic modelName);
var datasetRO = workspace_readonly.Databases.FindByName(semantic modelName);
if (datasetRW == null || datasetRO == null)
{
throw new ApplicationException("Database cannot be found!");
}
datasetRW.Refresh();
datasetRO.Refresh();
Console.WriteLine($"LastUpdated: {datasetRW.LastUpdate} (readwrite) {datasetRO.LastUpdate} (readonly)");
Console.WriteLine($"LastProcessed: {datasetRW.LastProcessed} (readwrite) {datasetRO.LastProcessed} (readonly)");
Console.WriteLine($"LastSchemaUpdate: {datasetRW.LastSchemaUpdate} (readwrite) {datasetRO.LastSchemaUpdate} (readonly)\n");
}
Console.WriteLine("Test completed. Press any key to exit.");
Console.Read();
Use the code below to compare the metadata of the primary read-write semantic model with the metadata of a read-only replica. Replace <WorkspaceUrl>
with your workspace's URL, and <DatasetName>
with your semantic model's name.
string workspaceUrl = "<WorkspaceUrl>"; // Replace <WorkspaceUrl> with the URL of your workspace
string datasetName = "<DatasetName>"; // Replace <DatasetName> with the name of your semantic model
using (var workspace_readwrite = new Microsoft.AnalysisServices.Tabular.Server())
using (var workspace_readonly = new Microsoft.AnalysisServices.Tabular.Server())
{
workspace_readwrite.Connect(workspaceUrl + "?readwrite");
workspace_readonly.Connect(workspaceUrl + "?readonly");
var datasetRW = workspace_readwrite.Databases.FindByName(datasetName);
var datasetRO = workspace_readonly.Databases.FindByName(datasetName);
if (datasetRW == null || datasetRO == null)
{
throw new ApplicationException("Database cannot be found!");
}
string tmslRW = Microsoft.AnalysisServices.Tabular.JsonSerializer.SerializeDatabase(datasetRW);
string tmslRO = Microsoft.AnalysisServices.Tabular.JsonSerializer.SerializeDatabase(datasetRO);
if (tmslRW != tmslRO)
{
Console.WriteLine("The replicas are out of sync.\n");
}
else
{
Console.WriteLine("The replicas are in sync.\n");
}
}
Console.WriteLine("Test completed. Press any key to exit.");
Console.Read();
Use ADOMD.NET
to query the data in the replicas. Replace <WorkspaceUrl>
with your workspace's URL, and <DatasetName>
with your semantic model's name.
string workspaceUrl = "<WorkspaceUrl>"; // Replace WorkspaceUrl with the URL of your workspace
string datasetName = "<DatasetName>"; // Replace DatasetName with the name of your semantic model
string daxQuery = "Evaluate SUMMARIZECOLUMNS(RefreshTimeTable[Time])";
using (var connectionRW = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection())
using (var connectionRO = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection())
{
connectionRW.ConnectionString = $"Data Source={workspaceUrl}?readwrite;Catalog={datasetName}";
connectionRO.ConnectionString = $"Data Source={workspaceUrl}?readonly;Catalog={datasetName}";
connectionRW.Open();
connectionRO.Open();
var cmd = new Microsoft.AnalysisServices.AdomdClient.AdomdCommand(daxQuery);
string resultRW = string.Empty;
string resultRO = string.Empty;
cmd.Connection = connectionRW;
using (var reader = cmd.ExecuteReader())
{
while (reader.Read())
{
resultRW = reader.GetString(0);
}
}
cmd.Connection = connectionRO;
using (var reader = cmd.ExecuteReader())
{
while (reader.Read())
{
resultRO = reader.GetString(0);
}
}
if (resultRW != resultRO)
{
Console.WriteLine("The replicas are out of sync.\n");
}
else
{
Console.WriteLine("The replicas are in sync.\n");
}
}
Console.WriteLine("Test completed. Press any key to exit.");
Console.Read();
Events
Power BI DataViz World Championships
Feb 14, 4 PM - Mar 31, 4 PM
With 4 chances to enter, you could win a conference package and make it to the LIVE Grand Finale in Las Vegas
Learn moreTraining
Learning path
Work with semantic models in Microsoft Fabric - Training
Designing reports for enterprise scale requires more than just connecting to data. Understanding semantic models and strategies for scalability and lifecycle management are key to a successful enterprise implementation. This learning path helps you prepare for the Fabric Analytics Engineer Certification.
Certification
Microsoft Certified: Azure Cosmos DB Developer Specialty - Certifications
Write efficient queries, create indexing policies, manage, and provision resources in the SQL API and SDK with Microsoft Azure Cosmos DB.