Skip to content

Commit

Permalink
Merge pull request microsoft#159 from microsoft/dev/tsdag/AddAlmAdmin…
Browse files Browse the repository at this point in the history
…APISample

Dev/tsdag/add alm admin api sample
  • Loading branch information
TslilD authored Jun 20, 2021
2 parents b5af7dd + d8c7b9a commit 8276389
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ function populateSelectList(componentType, componentListEndpoint, componentConta

// Populate select list
for (let i = 0; i < sortedList.length; i++) {
// Show id in option if title property is empty
componentContainer.append(
$("<option />")
.text(sortedList[i][componentDisplayName])
.text(sortedList[i][componentDisplayName] || sortedList[i].id)
.val(sortedList[i].id)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ function populateSelectList(componentType, componentListEndpoint, componentConta

// Populate select list
for (let i = 0; i < sortedList.length; i++) {
// Show id in option if title property is empty
componentContainer.append(
$("<option />")
.text(sortedList[i][componentDisplayName])
.text(sortedList[i][componentDisplayName] || sortedList[i].id)
.val(sortedList[i].id)
);
}
Expand Down
5 changes: 2 additions & 3 deletions NodeJS/Embed for your customers/AppOwnsData/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ app.get('/getEmbedToken', async function (req, res) {
// Validate whether all the required configurations are provided in config.json
configCheckResult = utils.validateConfig();
if (configCheckResult) {
return {
"status": 400,
return res.status(400).send({
"error": configCheckResult
};
});
}
// Get the details like Embed URL, Access token and Expiry
let result = await embedToken.getEmbedInfo();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# This sample script calls the Power BI admin API to programmatically add admin to the pipeline that the workspace is assigned to.
# this script requires user to be Power BI Service administrator or global tenant admin

# For documentation, please see:
# https://docs.microsoft.com/en-us/rest/api/power-bi/admin/pipelines-update-user-as-admin

# Instructions:
# 1. Install PowerShell (https://msdn.microsoft.com/en-us/powershell/scripting/setup/installing-windows-powershell)
# and the Power BI PowerShell cmdlets (Install-Module MicrosoftPowerBIMgmt)
# https://docs.microsoft.com/en-us/powershell/power-bi/overview?view=powerbi-ps
# 2. Run PowerShell as an administrator
# 3. Fill in the parameters below
# 4. Change PowerShell directory to where this script is saved
# 5. > Admin-DeploymentPipelines-AddUserToWorkspacePipeline.ps1

# Parameters - fill these in before running the script!
# =====================================================

$workspaceName = " FILL ME IN " # The name of the workspace
$userUpn = " FILL ME IN " # The UPN of the user to be added to the pipeline

# End Parameters =======================================

# Login to the Power BI service
Connect-PowerBIServiceAccount | Out-Null

try {
# Get workspace
$workspace = (Invoke-PowerBIRestMethod -Url "admin/Groups?`$top=100&`$filter=name eq '$workspaceName'" -Method Get | ConvertFrom-Json).Value

if(!$workspace) {
Write-Host "A workspace with the requested name was not found"
return
}

if($workspace.Length -gt 1){
Write-Host "workspace name match multiple instances"
return
}

if(!$workspace.pipelineId){
Write-Host "workspace isn't assigned to a pipeline"
return
}

# Construct the request url and body
$url = "admin/pipelines/{0}/users" -f $workspace.pipelineId

$body = @{
identifier = $userUpn
accessRight = "Admin"
principalType = "User"
} | ConvertTo-Json

# Send the request
Invoke-PowerBIRestMethod -Url $url -Method Post -Body $body

} catch {
$errmsg = Resolve-PowerBIError -Last
$errmsg.Message
}

0 comments on commit 8276389

Please sign in to comment.