Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pac data export auth issues via az devops pipelines #347

Open
jbuenoliveira opened this issue Nov 10, 2022 · 0 comments
Open

pac data export auth issues via az devops pipelines #347

jbuenoliveira opened this issue Nov 10, 2022 · 0 comments

Comments

@jbuenoliveira
Copy link

jbuenoliveira commented Nov 10, 2022

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

  1. Install Microsoft.PowerApps.CLI via NuGet package manager
  2. Retrieve PAC CLI tools path
  3. Authenticate with user auth profile (--username "[email protected]" --password "***")
    • pac data export isn't working with application auth profile (--applicationId 00000000-0000-0000-0000-000000000000 --clientSecret "***" --tenant 00000000-0000-0000-0000-000000000000).
  4. 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 --async parameter option is not available for pac data export. (NICE to have)
  • pac data documentation is not up to date with the authentication profiles (limitations) described above.

Screenshot:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant