admin管理员组文章数量:1418112
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
本文标签:
版权声明:本文标题:power platform - when using powershell inline script set command in yaml pipeline, it doesn't complete - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745271079a2650893.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