Using Set-AdminPowerAppEnvironmentBackupRetentionPeriod is not working in my YAML-pipeline. I've tried the following steps below and it keeps on going untill it will be automatically cancel the job.
This is my pipeline and the set command that i'm using.
stages:
stage: Power_Platform_Environment
displayName: 'PS'
jobs:
- job: Create_Power_Platform_Environment
displayName: 'PS'
steps:
- task: PowerPlatformToolInstaller@2
displayName: "Power Platform Tool Installer"
inputs:
DefaultVersion: true
AddToolsToPath: true
- task: PowerPlatformCreateEnvironment@2
displayName: 'Platform Create Environment'
inputs:
authenticationType: 'PowerPlatformSPN'
PowerPlatformSPN: 'CZ-PowerPlatform-LowCode-PPAdmin'
DisplayName: '$(EnvironmentName)'
EnvironmentSku: 'Production'
LocationName: 'europe'
LanguageName: 'English'
CurrencyName: 'EUR'
DomainName: '$(DomainName)'
SecurityGroupId: '$(SecurityGroupId)'
name: sv1
- task: PowerPlatformSetConnectionVariables@2
displayName: 'Set Connection Variables'
inputs:
authenticationType: 'PowerPlatformSPN'
PowerPlatformSPN: 'CZ-PowerPlatform-LowCode-PPAdmin'
name: sv2
- task: PowerShell@2
displayName: Powershell Install-Update PowerApps Module
inputs:
targetType: "Inline"
script:
Install-Module -Name Microsoft.PowerApps.Administration.PowerShell -Force -AllowClobber -Scope AllUsers
- task: PowerShell@2
displayName: Powershell Import PowerApps Module
inputs:
targetType: "Inline"
script:
Import-Module -Name Microsoft.PowerApps.Administration.PowerShell -Verbose
- task: PowerShell@2
displayName: Connect-SPN
inputs:
targetType: 'inline'
script: |
Write-Host "$(sv2.BuildTools.ApplicationId)"
Write-Host "$(sv2.BuildTools.ClientSecret)"
Write-Host "$(sv2.BuildTools.TenantId)"
pac auth create --name SPN-PPAdmin --environment $(sv1.BuildTools.EnvironmentUrl) --applicationId $(sv2.BuildTools.ApplicationId) --clientSecret $(sv2.BuildTools.ClientSecret) --tenant $(sv2.BuildTools.TenantId)
- task: PowerShell@2
displayName: 'Set Retention period to 28 days'
inputs:
targetType: 'inline'
script: |
# Write your PowerShell commands here.
Set-AdminPowerAppEnvironmentBackupRetentionPeriod -EnvironmentName $(sv1.BuildTools.EnvironmentUrl) -NewBackupRetentionPeriodInDays 28
Because using an azure agent, the powershell needs to have installed the module Microsoft.PowerApps.Administration.PowerShell. When importing this module with the -verbose parameter it shows me the right import, so succesful.
then I'm trying to get connected to my Service Principle, also succesfully.
Last step is setting the backup retention period to 28 days. This task will continue untill cancelled.
i've tried to change the period normally withing powershell, this works well.
For now i've fixed the issue by using pac cli commands in my powershell task.
pac auth create
pac auth update
pac admin set-backup-retention-period