ProvisionSample/Program.cs
/// <summary>
/// Imports a Power BI Desktop file (pbix) into the Power BI Embedded service
/// </summary>
/// <param name="workspaceCollectionName">The Power BI workspace collection name</param>
/// <param name="workspaceId">The target Power BI workspace id</param>
/// <param name="datasetName">The dataset name to apply to the uploaded dataset</param>
/// <param name="filePath">A local file path on your computer</param>
/// <returns></returns>
Imports a Power BI Desktop file (pbix) into the Power BI Embedded service
Imports a Power BI Desktop file ( pbix ) into the Power BI Embedded service
static async Task<Import> ImportPbix(string workspaceCollectionName, string workspaceId, string datasetName, string filePath)
        {
            using (var fileStream = File.OpenRead(filePath))
            {
                using (var client = await CreateClient())
                {
                    var import = await client.Imports.PostImportWithFileAsync(workspaceCollectionName, workspaceId, fileStream, datasetName);
                    while (import.ImportState != "Succeeded" && import.ImportState != "Failed")
                    {
                        import = await client.Imports.GetImportByIdAsync(workspaceCollectionName, workspaceId, import.Id);
                        Console.WriteLine("Checking import state... {0}", import.ImportState);
                        Thread.Sleep(1000);
                    }
                    return import;
                }
            }
        }
static async Task < Import > ImportPbix ( string workspaceCollectionName , string workspaceId , string datasetName , string filePath ) { using ( var fileStream = File . OpenRead ( filePath ) ) { using ( var client = await CreateClient ( ) ) { var import = await client . Imports . PostImportWithFileAsync ( workspaceCollectionName , workspaceId , fileStream , datasetName ) ; while ( import . ImportState != " " && import . ImportState != " " ) { import = await client . Imports . GetImportByIdAsync ( workspaceCollectionName , workspaceId , import . Id ) ; Console . WriteLine ( " " , import . ImportState ) ; Thread . Sleep ( 1000 ) ; } return import ; } } }
Imports a Power BI Desktop file (pbix) into the Power BI Embedded service
Imports a Power BI Desktop file ( pbix ) into the Power BI Embedded service
// Import PBIX file from the file stream // Example of polling the import to check when the import has succeeded.
None
workspaceCollectionName
string
The Power BI workspace collection name
The Power BI workspace collection name
workspaceId
string
The target Power BI workspace id
The target Power BI workspace id
datasetName
string
The dataset name to apply to the uploaded dataset
The dataset name to apply to the uploaded dataset
filePath
string
A local file path on your computer
A local file path on your computer