microsoft / microsoft/powerplatform-vscode
`pac data export` auth issues via az devops pipelines
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 277
- Forks
- 60
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 14
Description
Issue description
The local execution is working as predicted, however the automation of pac data export via az devops pipelines isn't.
Steps to reproduce the issue via az devops pipelines
- Install
Microsoft.PowerApps.CLIvia NuGet package manager - Retrieve PAC CLI tools path
- Authenticate with user auth profile (
--username "username@domain.com" --password "***")pac data exportisn't working with application auth profile (--applicationId 00000000-0000-0000-0000-000000000000 --clientSecret "***" --tenant 00000000-0000-0000-0000-000000000000).
- Execute
pac data export -sf "./schema.xml" -env "https://server.crm4.dynamics.com/" -o -v- Schema file created and tested using Configuration Migration Tool.
Sample YAML pipeline:
parameters:
- name: environmentName
type: string
default: ''
- name: environmentUrl
type: string
default: ''
- name: username
type: string
default: ''
- name: password
type: string
default: ''
steps:
- task: NuGetToolInstaller@1
displayName: 'Install NuGet Tool'
- task: NuGetCommand@2
displayName: 'Install Microsoft.PowerApps.CLI nuget package'
inputs:
command: custom
arguments: 'install "Microsoft.PowerApps.CLI" -OutputDirectory "$(System.DefaultWorkingDirectory)\packages"'
- powershell: |
Write-Host "##[debug]Retrieve/Set PAC CLI tools path"
$pacNugetFolder = Get-ChildItem "$(System.DefaultWorkingDirectory)\packages" | Where-Object {$_.PSIsContainer -and ($_.Name -match "Microsoft.PowerApps.CLI.")} | Sort CreationTime -Descending | Select-Object -First 1 -Unique
$pacPath = $pacNugetFolder.FullName + "\tools"
$env:PATH = $env:PATH + ";" + "$pacPath"
Write-Host "##[debug]Enable telemetry"
pac telemetry enable
Write-Host "##[debug]Erase all authentication profiles"
pac auth clear
Write-Host "##[debug]Create authentication profile"
pac auth create `
--name "${{parameters.environmentName}}" `
--url "${{parameters.environmentUrl}}" `
--username "${{parameters.username}}" `
--password "${{parameters.password}}"
Write-Host "##[debug]Select Environment"
pac auth select --name "${{parameters.environmentName}}"
Write-Host "##[debug]Export data"
pac data export -sf "$(System.DefaultWorkingDirectory)\schema.xml" -env "${{parameters.environmentUrl}}" -o -v
workingDirectory: $(System.DefaultWorkingDirectory)
displayName: 'Export data'
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(System.DefaultWorkingDirectory)\data.zip'
artifact: 'publish'
publishLocation: 'pipeline'
displayName: 'Publish data.zip'
What's the expected result?
- Compressed CRM data file:
data.zip(default data zip file).
What's the actual result?
- No compressed data with exception:
Error: An error occurred while sending the request.
The underlying connection was closed: An unexpected error occurred on a send.
Authentication failed because the remote party has closed the transport stream.
Additional details / screenshot
- PAC CLI Version: 1.19.4
- Attempted alternative agent pools as well, but the behavior remained the same.
- Noticed that the
--asyncparameter option is not available forpac data export. (NICE to have) - pac data documentation is not up to date with the authentication profiles (limitations) described above.
Screenshot:

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository files or tests are named. Start with the supplied Azure DevOps YAML pipeline and reproduce the pac auth create and pac data export steps using PAC CLI 1.19.4, comparing user and application authentication. Done means identifying whether the transport error is caused by an authentication limitation or the pipeline environment, and documenting the supported behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, powershell
- Domain
- authentication, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100