cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Microsoft
Microsoft

Automate PBIVIZ Cert Create and Install on Azure Devops CI/CD

In order to package a custom visual we need to run the below command :

 

pbiviz package

 

However a pre-requisite to this is the --create-cert and --install-cert steps.

 

Is it possible to automate the same on Azure Devops such that the CI can generate the required package. (*..pbiviz)

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Microsoft
Microsoft

Re: Automate PBIVIZ Cert Create and Install on Azure Devops CI/CD

We were able to automate the same on Azure Devops using the usual NPM tasks. However the trick here was 'install the certificate' and using powershell 'to import this on the cert store' before packaging and generating the *.pbiviz file.

 

Sample YAML file for reference - 

 

pool:
name: Azure Pipelines
steps:
- task: NodeTool@0
displayName: 'Use Node 10.x'
inputs:
versionSpec: 10.x
checkLatest: true

- task: Npm@1
displayName: 'npm install'
inputs:
workingDir: '$(System.DefaultWorkingDirectory)'
verbose: false

- task: Npm@1
displayName: 'npm test'
inputs:
command: custom
workingDir: '$(System.DefaultWorkingDirectory)'
verbose: false
customCommand: 'run test -- --reporter mocha-junit-reporter'
enabled: false

- task: Npm@1
displayName: 'npm install pbiviz'
inputs:
command: custom
workingDir: '$(System.DefaultWorkingDirectory)'
verbose: false
customCommand: 'install -g powerbi-visuals-tools'

- task: Npm@1
displayName: 'npm install cert'
inputs:
command: custom
workingDir: '$(System.DefaultWorkingDirectory)'
verbose: false
customCommand: 'run cert'

- powershell: |
$ExtensionFile = "C:\npm\prefix\node_modules\powerbi-visuals-tools\config.json"

$jsondata = Get-Content -Raw -Path $ExtensionFile | ConvertFrom-Json

CERTUTIL -f -p $jsondata.server.passphrase -importpfx “C:\npm\prefix\node_modules\powerbi-visuals-tools\certs\PowerBICustomVisualTest_public.pfx”
displayName: 'PowerShell Script - Import Pfx to Trusted Root '

- task: Npm@1
displayName: 'npm package'
inputs:
command: custom
workingDir: '$(System.DefaultWorkingDirectory)'
verbose: false
customCommand: 'run package'

- task: PublishBuildArtifacts@1
displayName: 'Publish artifacts: drop'
inputs:
PathtoPublish: dist

- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.SourcesDirectory)/coverage/cobertura-coverage.xml'
reportDirectory: '$(Build.SourcesDirectory)/coverage/'
enabled: false

- task: PublishTestResults@2
displayName: 'Publish Test Results **/test-results.xml'
inputs:
testResultsFiles: '**/test-results.xml'
enabled: false
a

View solution in original post

3 REPLIES 3
Highlighted
Microsoft
Microsoft

Re: Automate PBIVIZ Cert Create and Install on Azure Devops CI/CD

We were able to automate the same on Azure Devops using the usual NPM tasks. However the trick here was 'install the certificate' and using powershell 'to import this on the cert store' before packaging and generating the *.pbiviz file.

 

Sample YAML file for reference - 

 

pool:
name: Azure Pipelines
steps:
- task: NodeTool@0
displayName: 'Use Node 10.x'
inputs:
versionSpec: 10.x
checkLatest: true

- task: Npm@1
displayName: 'npm install'
inputs:
workingDir: '$(System.DefaultWorkingDirectory)'
verbose: false

- task: Npm@1
displayName: 'npm test'
inputs:
command: custom
workingDir: '$(System.DefaultWorkingDirectory)'
verbose: false
customCommand: 'run test -- --reporter mocha-junit-reporter'
enabled: false

- task: Npm@1
displayName: 'npm install pbiviz'
inputs:
command: custom
workingDir: '$(System.DefaultWorkingDirectory)'
verbose: false
customCommand: 'install -g powerbi-visuals-tools'

- task: Npm@1
displayName: 'npm install cert'
inputs:
command: custom
workingDir: '$(System.DefaultWorkingDirectory)'
verbose: false
customCommand: 'run cert'

- powershell: |
$ExtensionFile = "C:\npm\prefix\node_modules\powerbi-visuals-tools\config.json"

$jsondata = Get-Content -Raw -Path $ExtensionFile | ConvertFrom-Json

CERTUTIL -f -p $jsondata.server.passphrase -importpfx “C:\npm\prefix\node_modules\powerbi-visuals-tools\certs\PowerBICustomVisualTest_public.pfx”
displayName: 'PowerShell Script - Import Pfx to Trusted Root '

- task: Npm@1
displayName: 'npm package'
inputs:
command: custom
workingDir: '$(System.DefaultWorkingDirectory)'
verbose: false
customCommand: 'run package'

- task: PublishBuildArtifacts@1
displayName: 'Publish artifacts: drop'
inputs:
PathtoPublish: dist

- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.SourcesDirectory)/coverage/cobertura-coverage.xml'
reportDirectory: '$(Build.SourcesDirectory)/coverage/'
enabled: false

- task: PublishTestResults@2
displayName: 'Publish Test Results **/test-results.xml'
inputs:
testResultsFiles: '**/test-results.xml'
enabled: false
a

View solution in original post

Highlighted
MVP

Re: Automate PBIVIZ Cert Create and Install on Azure Devops CI/CD

Hi @safalkishore ,

 

The certificate is only needed if you want to use the visual with the Power BI Developer visual. All other action do not need the certificate, like pbiviz package and testing.

I am using the following yml to build, lint, test and package my custom visual via Azure DevOps: https://github.com/liprec/powerbi-hierarchySlicer/blob/master/azure-pipelines.yml

 

-JP

Highlighted
Microsoft
Microsoft

Re: Automate PBIVIZ Cert Create and Install on Azure Devops CI/CD

Thanks very much for this @jppp ! Will also check this out and switch as its cleaner. However I recollect that when I simply ran the 'pbiviz package' cmd on the pipelines agent, it did throw back an error that the cmd is missing the cert installed.

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021