无法通过Powershell Azure函数在应用程序服务中启用连续部署

问题描述 投票:0回答:1

我有一个Powershell Azure函数。此函数创建资源组和。Net Azure Function。我的Powershell Azure Function通过Management Identity登录并在创建的。Net AF中登录。我也有Azure Devops存储库

现在,我要在创建的。Net AF中启用Continuous Deployment。当我在门户网站上运行时,它可以运行;当我在Powershell中从计算机远程运行时,它可以运行。当我将相同的代码上传到Azure函数时,会发生错误。错误:参数x-ms-client-principal-name为null或为空。我附上下面的屏幕。

这就是设置部署中心的方式

$PropertiesObject = @{
        repoUrl = "xxx";
        branch ="master";
        isManualIntegration = $false;
        isGitHubAction = $false;
        deploymentRollbackEnabled = $false;
        isMercurial = $false ;
    }

    Set-AzResource -PropertyObject $PropertiesObject `
    -ResourceGroupName $rgName `
    -ResourceType "Microsoft.Web/sites/sourcecontrols" `
    -ResourceName "$($webappName)/web" `
    -ApiVersion 2018-11-01 -Force

从我的PowerShell远程登录:

Get-AzAccount

登录Powershell Azure功能:

Connect-AzAccount -Identity

错误:

    2020-03-20T08:53:01.044 [Information] INFORMATION: I034: Automate deployment properties set up
2020-03-20T08:53:01.430 [Error] ERROR: Set-AzResource : {"Code":"BadRequest","Message":"Parameter x-ms-client-principal-name is null or empty.","Target":null,"Details":[{"Message":"Parameter x-ms-client-principal-name is null or empty."},{"Code":"BadRequest"},{"ErrorEntity":{"ExtendedCode":"51011","MessageTemplate":"Parameter {0} is null or empty.","Parameters":["x-ms-client-principal-name"],"Code":"BadRequest","Message":"Parameter x-ms-client-principal-name is null or empty."}}],"Innererror":null}
At D:\home\site\wwwroot\Create\run.ps1:344 char:9
+         Set-AzResource -PropertyObject $PropertiesObject `
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : CloseError: (:) [Set-AzResource], ErrorResponseMessageException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.SetAzureResourceCmdlet
azure powershell azure-devops continuous-integration continuous-deployment
1个回答
1
投票

解决:回答...你不能。来源:https://docs.microsoft.com/.../active-directory-how ...简而言之:您不能使用系统分配的托管身份来授予特定应用程序注册的权限。

还有另一种方法是将来自devops的访问令牌放在回购URL之前,然后进行身份验证:3

© www.soinside.com 2019 - 2024. All rights reserved.