admin管理员组文章数量:1355535
I'm trying to upload a Symantic Model in a PowreBi Workspace, using the c# PowerBiClient. I'm using the following code:
public async Task<Import> UpsertDataSet(Guid groupId, string path, string displayName)
{
var pbiClient = await GetPowerBIClient() ?? throw new PowerBiException(PowerBiClientIsNull);
using var pbixStream = new FileStream(path, FileMode.Open, FileAccess.Read);
var import = await pbiClient.Imports.PostImportWithFileAsyncInGroup(groupId, pbixStream, displayName, nameConflict: ImportConflictHandlerMode.CreateOrOverwrite);
return await pbiClient.Imports.GetImportInGroupAsync(groupId, import.Id);
}
There are cases where the import.Datasets are not filled while the Model is uploaded.
I added and extra GetImportInGroupAsync to check if the model is updated. How come that the result is empty which the Model is updated
I'm trying to upload a Symantic Model in a PowreBi Workspace, using the c# PowerBiClient. I'm using the following code:
public async Task<Import> UpsertDataSet(Guid groupId, string path, string displayName)
{
var pbiClient = await GetPowerBIClient() ?? throw new PowerBiException(PowerBiClientIsNull);
using var pbixStream = new FileStream(path, FileMode.Open, FileAccess.Read);
var import = await pbiClient.Imports.PostImportWithFileAsyncInGroup(groupId, pbixStream, displayName, nameConflict: ImportConflictHandlerMode.CreateOrOverwrite);
return await pbiClient.Imports.GetImportInGroupAsync(groupId, import.Id);
}
There are cases where the import.Datasets are not filled while the Model is uploaded.
I added and extra GetImportInGroupAsync to check if the model is updated. How come that the result is empty which the Model is updated
Share Improve this question asked Mar 31 at 14:26 BartBart 3253 silver badges16 bronze badges1 Answer
Reset to default 0Apperently the PostImportWithFileAsyncInGroup returns directly and there is a need for polling the importstate
public async Task<Import> UpsertDataSet(Guid groupId, string path, string displayName)
{
var pbiClient = await GetPowerBIClient() ?? throw new PowerBiException(PowerBiClientIsNull);
using var pbixStream = new FileStream(path, FileMode.Open, FileAccess.Read);
var import = await pbiClient.Imports.PostImportWithFileAsyncInGroup(groupId, pbixStream,
datasetDisplayName: displayName,
nameConflict: ImportConflictHandlerMode.CreateOrOverwrite,
overrideModelLabel: true,
overrideReportLabel: true);
var importId = import.Id;
var retry = 0;
while (retry++ < MaxRetries)
{
var importState = ParseImportState(import.ImportState);
if (importState is ImportState.Succeeded)
{
logger.LogInformation("Dataset updated: - {Name} (Id: {Id})", import.Name, import.Id);
return import;
}
if (importState is ImportState.Failed)
{
throw new PowerBiException(ImportFailed);
}
await Task.Delay(500);
import = await pbiClient.Imports.GetImportInGroupAsync(groupId, importId);
}
throw new PowerBiException(ImportFailed);
}
private static ImportState ParseImportState(string state)
{
return state switch
{
"Succeeded" => ImportState.Succeeded,
"Failed" => ImportState.Failed,
"Publishing" => ImportState.Publishing,
_ => ImportState.Unknown
};
}
本文标签:
版权声明:本文标题:PowerBi PowerBiClient : PostImportWithFileAsyncInGroup sometimes results in no datasets, while datasets are updated - Stack Over 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743941089a2565576.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论