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.
Pipeline with tasks
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.
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.
Pipeline with tasks
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.
Share Improve this question edited Feb 4 at 7:58 Steven D asked Jan 31 at 9:46 Steven DSteven D 113 bronze badges 6 | Show 1 more comment1 Answer
Reset to default 0For 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
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745271079a4619748.html
$(sv1.BuildTools.EnvironmentUrl)
variable from. Also, is this being run from a MS-hosted or self-hosted agent? – GalnaGreta Commented Feb 1 at 9:08Set-AdminPowerAppEnvironmentBackupRetentionPeriod
cmdlet in my test, an authentication prompt appears, requiring me to log in to my Azure account. This issue seems to be related to the authentication prompt that appears when running the cmdlet. The pipeline waits for the login until it is canceled. To avoid this issue, please ensure that your account is logged in before you run the command. – Miao Tian Commented Feb 3 at 6:24Set-AdminPowerAppEnvironmentBackupRetentionPeriod
command recognizes the SPN authentication, you can try to combine the Connect-SPN and Set commands in the same PowerShell task to ensure the authentication context is maintained. – Miao Tian Commented Feb 4 at 9:15