Azure DevOps tasks for ALM4Dataverse with enhanced support for WorkloadIdentityFederation and ManagedServiceIdentity authentication in addition to traditional Service Principal authentication.
This extension provides an enhanced version of the Power Platform set-connection-variables task that supports modern authentication schemes including:
- WorkloadIdentityFederation - Secure, passwordless authentication using Azure AD Workload Identity Federation
- ManagedServiceIdentity - Passwordless authentication using an Azure-hosted managed identity
- Service Principal with Client Secret - Traditional SPN authentication with application ID and client secret
Sets ALM4DataverseSetConnectionVariables.* pipeline variables from a Power Platform service connection, providing downstream custom script tasks with a single source of truth for authentication credentials.
Key Enhancements:
- Full support for WorkloadIdentityFederation authentication scheme, enabling secure, passwordless authentication to Power Platform environments.
- Support for ManagedServiceIdentity authentication scheme, including user-assigned identities via
AZURE_CLIENT_IDand system-assigned identities via the host environment. - Sets the
AZURE_environment variables that allow many tools to authenticate automatically or easily.
The task sets the following pipeline variables:
ALM4DataverseSetConnectionVariables.EnvironmentUrl- The Power Platform environment URLALM4DataverseSetConnectionVariables.ApplicationId- Application/Service Principal IDALM4DataverseSetConnectionVariables.TenantId- Azure AD Tenant IDALM4DataverseSetConnectionVariables.AuthenticationType- The authentication type used (WorkloadIdentityFederation, ManagedServiceIdentity, or ClientSecret)
The task also sets the AZURE_ environment variables:
AZURE_TENANT_IDAZURE_CLIENT_IDAZURE_CLIENT_SECRETfor client secret auth only - This is a secret, so must be specifically mapped to any tasks that need itAZURE_AUTHORITY_HOSTfor Workload Identity Federated auth onlyAZURE_FEDERATED_TOKEN_FILEfor Workload Identity Federated auth only
- An Azure DevOps organization
- A Power Platform environment
- A service connection configured in Azure DevOps
- In Azure AD, create an App Registration
- Configure Federated Credentials for Azure DevOps
- Grant the app appropriate permissions to your Power Platform environment
- Create a service connection in Azure DevOps with:
- Authentication scheme: WorkloadIdentityFederation
- Service Principal ID
- Tenant ID
- Run the agent on an Azure resource that has a managed identity available
- Grant that managed identity appropriate permissions to your Power Platform environment
- Create a Power Platform service connection in Azure DevOps with:
- Authentication scheme: ManagedServiceIdentity
- Tenant ID when required by your configuration
- Client ID when using a user-assigned managed identity
- Create an App Registration in Azure AD
- Create a client secret
- Grant permissions to Power Platform environment
- Create a service connection with:
- Application ID
- Client Secret
- Tenant ID
- task: ALM4DataverseSetConnectionVariables@1
inputs:
authenticationType: 'PowerPlatformSPN'
PowerPlatformSPN: 'MyPowerPlatformConnection'
Environment: 'https://myorg.crm.dynamics.com'
setAzureEnvironmentVariables: true # Enable automatic Azure SDK integration- authenticationType (required): Must be
PowerPlatformSPN(Service Principal) - PowerPlatformSPN: Service connection name for Service Principal authentication
After running the task, use the output variables in subsequent steps:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
Write-Host "Environment URL: $(ALM4DataverseSetConnectionVariables.EnvironmentUrl)"
Write-Host "Application ID: $(ALM4DataverseSetConnectionVariables.ApplicationId)"Azure SDK environment variables are set automatically:
- task: ALM4DataverseSetConnectionVariables@1
inputs:
authenticationType: 'PowerPlatformSPN'
PowerPlatformSPN: 'MyPowerPlatformConnection'
Environment: 'https://myorg.crm.dynamics.com'
# Now any tool using DefaultAzureCredential will automatically authenticate
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
pac auth create --managedIdentity --environment $(ALM4DataverseSetConnectionVariables.EnvironmentUrl)
env:
# This is a secret, so must be specifically mapped
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)npm installnpm run buildnpm install -g tfx-cli
tfx extension create --manifest-globs vss-extension.json.
├── src/
│ ├── tasks/
│ │ └── set-connection-variables/
│ │ ├── index.ts # Main task implementation
│ │ └── task.json # Task metadata
│ ├── params/
│ │ └── auth/
│ │ ├── getAuthenticationType.ts
│ │ ├── getEndpointName.ts
│ │ └── isRunningOnAgent.ts
│ └── host/
│ └── PipelineVariables.ts # Variable name definitions
├── dist/ # Compiled output
├── package.json
├── tsconfig.json
└── vss-extension.json # Extension manifest
This implementation is based on the Microsoft Power Platform Build Tools:
With extensions to support WorkloadIdentityFederation and ManagedServiceIdentity authentication as implemented in the getCredentials.ts module.
MIT
Contributions are welcome! Please feel free to submit a Pull Request.