我已经创建了一个Azure DevOps管道。
99%的管道调用PowerShell脚本(PowerShell核心脚本类型)。
在Power脚本中是对AZ模块的调用--这一切都很好。
现在我必须在DevOps管道中添加一个新步骤来在SQL服务器上设置'VulnerabilityAssessment‘,但是这次我需要调用模块' set -Azcontext’,作为PowerShell脚本的一部分,如下所示.
[CmdletBinding()]
param(
$prgname,
$psqlservername,
$psaname,
$pnotificationmmail = 'john.doe@hotmail.com',
$psubscriptionname = 'ABC'
)
#debug
#Get-Module -Name AZ -ListAvailable
# working in powershell and need to set the correct subscription in powershell (ABC)
Set-Azcontext -Subscription "ABC"
#Enable-AzSqlServerAdvancedDataSecurity -ResourceGroupName $prgname -ServerName $pservername -DoNotConfigureVulnerabilityAssessment
# https://learn.microsoft.com/en-us/powershell/module/az.sql/update-
azsqlservervulnerabilityassessmentsetting?view=azps-7.5.0
#Update-AzSqlServerVulnerabilityAssessmentSetting -ResourceGroupName $prgname -ServerName $pservername -StorageAccountName $psaname -ScanResultsContainerName "vulnerability-assessment" -RecurringScansInterval Weekly -EmailAdmins $true -NotificationEmail @pnotificationmmail当Azure devOps管道运行时,它在步骤中失败.Set-Azcontext -Subscription "ABC“
更新-漏洞-评估。ps1:术语“Set-Azcontext”不被识别为cmdlet、函数、脚本文件或可执行程序的名称。检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后再试一次。
devOps进程运行在Azure代理上。它看起来像一个模块是不可用的或加载的。
也许我需要安装/加载包含“Set-Azcontext”的模块,作为powershell脚本的一部分?(如果是这样的话,我该如何做?)
或
安装代理的新的capibility,以安装包含“Set-Azcontext”的模块?(如果是的话,我如何做到这一点)
发布于 2022-05-20 17:29:54
而是通过Azure管道中的ARM模板来设置Azure SQL server的漏洞
https://stackoverflow.com/questions/72317896
复制相似问题