PowerBIDevIAD Presentation
PowerBIDevIAD Presentation
Developer in a Day
June 2022 release
Get started
Lab document available at <CourseFolder>\PowerBIDevIAD\Lab00A
1. Get started
Modules include:
01: Introduction to Power BI embedded analytics
02: Select a Power BI embedded analytics product
03: Set up permissions to embed Power BI content
04: Embed Power BI content
05: Integrate content with the Power BI client APIs
06: Enforce data permissions for Power BI embedded analytics
07: Automate Power BI solution management
Module 01
Introduction to Power BI
embedded analytics
© 2022 Microsoft. All rights reserved.
Module outline
01: Introduction to Power BI embedded analytics
• Introduce Power BI
• Power BI roles
• Power BI licensing
• Power BI core concepts
• Introduce embedded analytics
200+ apps
</>
Power BI
Power BI Power BI Power BI Power BI Power BI
Report
Desktop Service Premium Report Server Embedded
Builder
Get Data
Easily connect, clean, and mashup data
Analyze
Build powerful models and flexible measures
Visualize
Create stunning interactive reports
Publish
Share insights with others
Collaborate
Empower your organization with
self-service analytics
© 2022 Microsoft. All rights reserved.
Introduce Power BI
Product portfolio » Power BI Report Builder
Get Data
From Power BI, or cloud and on-prem sources
Design
Create pixel-perfect report layouts
Visualize
Use mature and rich data regions
Publish
Share insights with others
Print
Produce multi-page report documents
Power BI Premium
Business user
Business analyst
BI professional
Developer
Administrator
© 2022 Microsoft. All rights reserved.
Power BI roles
Developer
• Power BI service
• Workspaces
• Datasets
• Reports
• Dashboards
• Q&A
Can be multi-
page, but fixed
page size
Can
overflow
to multiple
pages
• A Power BI dashboard is
intended to monitor data
• Displays a collection of
up-to-date data in tiles on a
single pane
• Typically, tiles are pinned from
report visuals or Q&A responses
Enter a
question
1. Create a workspace
2. Publish a report
3. Create a report
Power BI site
http://powerbi.com
Power BI community
http://community.powerbi.com/
Power BI ideas
http://ideas.powerbi.com/
Power BI blog
https://blog.powerbi.com/
Tip: Power BI is evolving at a
Power BI documentation rapid rate—one of the best ways
to keep pace with updates is to
https://docs.microsoft.com/power-bi/ subscribe to the Power BI blog
Microsoft Learn
https://docs.microsoft.com/learn/
Module 02
• Embed scenarios
• Select a Power BI embedded analytics product
• Manage resources and scale requirements
• Set up a development environment
• Development methodology
A SKU P SKU
Product Power BI Embedded Power BI Premium
Purchase Azure portal Office 365
Use cases • Embed content in apps • Embed content in apps
• Share content with Power BI free users outside the
Power BI service
• Embed in other SaaS apps (Teams and SharePoint)
• Share content with Power BI free users through the
Power BI service
Billing Hourly Monthly
Commitment None Monthly/Yearly
Difference Full elasticity: scale up, scale down, pause, Combine embedding in apps and use the Power BI
resume. Service in the same capacity.
ARM API with PowerShell. Power BI Report Server included.
• Typically:
• Enterprises buy Power BI Premium
• ISVs buy Azure Power BI Embedded
• However, there are no restrictions on which product a customer buys
• Examples:
• Enterprises may decide to use A SKUs if they are only interested in building line of business
apps and embedding analytics into them, and are not interested in using the pre-packaged
Power BI service
• ISV (typically large) may want to use a P SKU to get the additional benefits of the pre-
packaged Power BI service within their organization, as well as embed in their apps
1. Create a workspace
2. Add Power BI content
3. Register an Azure AD application
4. Import NuGet packages
5. Add app settings
6. Embed Power BI content
7. Enhance end user experience This methodology is simply a guide. In
this course it is also used to provide
8. Configure data permissions structure for the modules and lessons.
Power BI pricing
https://powerbi.microsoft.com/pricing/
Module 03
Interactive
auth flow
© 2022 Microsoft. All rights reserved.
Acquire an access token
Scenario » For your customers
• When using your app, the app user does not require a Power BI
account or license
• Any authentication method can be used by the app
• A dedicated Azure AD identity is used to authenticate with Power BI:
• Service principal
• Master user account
• An embed token is required to embed Power BI content when using
an effective identity
• Requires specific product (SKUs: A or P)
This course
focuses mainly
Non-interactive on this scenario
auth flow
© 2022 Microsoft. All rights reserved.
Acquire an access token
Scenario » For your customers » Embedding identity types
• Admin portal
» Tenant settings
» Developer settings
• Power BI admin
permissions are
required
• Generally:
• Service principal is a good choice for production:
• It is the recommended approach by Azure AD
• It supports better automation and scale
• There is less management overhead
• But—it requires Azure AD and Power BI admin rights to setup and manage
• Master user is a good choice for dev/test:
• It is easy to setup
• It can be used to sign in to the Power BI service to help troubleshoot issues
• But—it requires a Power BI Pro license
This course
focuses mainly
Non-interactive on this scenario
auth flow
© 2022 Microsoft. All rights reserved.
Demo 03A
Set up permissions
Set up permissions
You must successfully complete Lab 01A before commencing this lab
Lab document available at <CourseFolder>\PowerBIDevIAD\Lab03A
1. Set up permissions
Module 04
• Development methodology
1. Create a workspace
2. Add Power BI content
3. Register an Azure AD application
4. Import NuGet packages
5. Add app settings
6. Embed Power BI content
7. Enhance end user experience
8. Configure data permissions
• Microsoft.Identity.Web package:
• Enables ASP.NET Core web apps and web APIs to use the Microsoft identity
platform
• Microsoft.PowerBI.Api package:
• A .NET Client library for Microsoft Power BI public REST endpoints
• Provides access to Power BI workspaces, and content identifiers (GUIDS) for
datasets, reports, dashboards, tiles, etc.
{
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"Domain": "deviad.onmicrosoft.com",
"TenantId": "c01bee20-ed93-4b74-80f8-23144cf2a62b",
"ClientId": "d1c92721-a353-4f6e-a16d-a1ee8f67b0b1",
"ClientSecret": "OTZkM2NmNjAtMWNlZC00YjEyLWI0MzEtMjM2YmE3MmRiYzQ3="
},
"PowerBi": {
"ServiceRootUrl": "https://api.powerbi.com/",
"WorkspaceId": "abcd1234-0123-4567-8901-abcdef123456"
}
…
• Reports
• type: report
• settings*:
• panes: filters, pageNavigation, and other panes
• localeSettings: language and formatLocale (e.g., “en”)
• And many others…
• pageName*
• permissions*: Read | ReadWrite | Copy | Create | All
• viewMode*: View | Edit
Embed token must have
acquired relevant privileges
* Optional
© 2022 Microsoft. All rights reserved.
Development methodology
6: Embed Power BI content » Configuration object » Resource-specific settings
• Report visuals
• type: visual
• pageName
• visualName
• settings*:
• localeSettings: language and formatLocale (e.g., “en”)
• And many others…
• height*
• width*
* Optional
© 2022 Microsoft. All rights reserved.
Development methodology
6: Embed Power BI content » Configuration object » Resource-specific settings
• Dashboards:
• type: dashboard
• pageView*: actualSize | fitToWidth | oneColumn
• Dashboard tiles:
• type: tile
* Optional
© 2022 Microsoft. All rights reserved.
Development methodology
6: Embed Power BI content » Configuration object » Resource-specific settings
• Q&A experience:
• type: qna
ResultOnly mode uses a pre-
• viewMode: Interactive | ResultOnly populated question
• question: Q&A question
Interactive: optional
ResultOnly: mandatory
* Optional
© 2022 Microsoft. All rights reserved.
Development methodology
6: Embed Power BI content » Embedding
powerbi.embed(…);
Microsoft.PowerBI.JavaScript
https://www.nuget.org/packages/Microsoft.PowerBI.JavaScript/
Module 05
• Development methodology
1. Create a workspace
2. Add Power BI content
3. Register an Azure AD application
4. Import NuGet packages
5. Add app settings
6. Embed Power BI content
7. Enhance end user experience
8. Configure data permissions
• powerbi-client package:
• Contains a suite of JavaScript web components and APIs for integrating Power
BI into apps
• powerbi-models package:
• Contains JavaScript and TypeScript object models
• powerbi-report-authoring package:
• Contains functionality to help edit Power BI reports programmatically
• It is an extension of powerbi-client library
• powerbi-client-react package:
• Helps easily embed Power BI content in a React web application
© 2022 Microsoft. All rights reserved.
Development methodology
7: Enhance end user experience » In-context analytics workflow
Module 06
• Development methodology
1. Create a workspace
2. Add Power BI content
3. Register an Azure AD application
4. Import NuGet packages
5. Add app settings
6. Embed Power BI content
7. Enhance end user experience
8. Configure data permissions
Model data
Power BI
Azure AS
SQL Server
Import DirectQuery Analysis Services
can also be used
• Roles
• Rules
• Static rules
• Dynamic rules
There is no need to
create any roles if
all users require
access to all data
Effective username
value is passed as
“other user”
Module 07
$authResult = Connect-AzureAD
$tenantId = $authResult.TenantId.ToString()
$tenantDomain = $authResult.TenantDomain
$userAccountId = $authResult.Account.Id
$user = Get-AzureADUser -ObjectId $userAccountId
…
…
# Create the app secret
$newGuid = New-Guid
$appSecret = ([System.Convert]::ToBase64String([System.Text.Encoding]
::UTF8.GetBytes(($newGuid))))+"="
$startDate = Get-Date
$passwordCredential = New-Object -TypeName
Microsoft.Open.AzureAD.Model.PasswordCredential
$passwordCredential.StartDate = $startDate
$passwordCredential.EndDate = $startDate.AddYears(1)
$passwordCredential.KeyId = $newGuid
$passwordCredential.Value = $appSecret
…
…
# Create the Azure AD app
$replyUrl = "https://localhost:5001/signin-oidc"
$aadApplication = New-AzureADApplication `
-DisplayName $appDisplayName `
-PublicClient $false `
-AvailableToOtherTenants $false `
-ReplyUrls @($replyUrl) `
-Homepage $replyUrl `
-PasswordCredentials $passwordCredential
…
…
# Create the app's service principal
$appId = $aadApplication.AppId
$appObjectId = $aadApplication.ObjectId
$serviceServicePrincipal = New-AzureADServicePrincipal -AppId $appId
$serviceServicePrincipalObjectId = $serviceServicePrincipal.ObjectId
# Add the service principal of the new app as member of thesecurity group
Add-AzureADGroupMember -ObjectId $($adSecurityGroup.ObjectId) `
-RefObjectId $($serviceServicePrincipalObjectId)
…
Connect-PowerBIServiceAccount | Out-Null
• Steps:
• Create a service principal
• Add the service principal as a contributor to golden workspace
• Using the new service principal:
• Create a new workspace for the new tenant
• Publish the golden content into the new workspace
• Update the dataset to connect to real tenant data (either update the data
source or import a new dataset)
• Assign the new workspace to a capacity
Report 1 Admin
Report 2
Tenant 1 Workspace
Report 3
Tenant 1 Dataset
Admin
Report 1
Report 2
Content
publishers Report 3
Capacity Assigned
Report 2
Tenant 1 Workspace Tenant 2 Workspace
Report 3
Tenant 1 Dataset Tenant 2 Dataset
Admin
Report 1 Report 1
Report 2 Report 2
Content
publishers Report 3 Report 3