我有一个由托管标识支持的 Azure 函数。
在同一AD上,有Office 365,其中包含一个名为"demonews"的SharePoint网站。
如何向组"demonews"添加权限/添加托管标识,以便它可以访问SharePoint API?
我尝试在 SharePoint 网站上添加成员,我尝试在 AD 组上添加成员。下拉列表找不到托管标识。
我认为这是您要找的:
https://finarne.wordpress.com/2019/03/17/azure-function-using-a-managed-identity-to-call-sharepoint-online/
实质上,你将获得适用于Office 365 SharePoint的Azure服务主体以及角色。
#Get the sharePoint principal
$sharePoint = (Get-AzureADServicePrincipal -SearchString “Office 365 SharePoint”).ObjectId
#Get the Roles for that principal
$appRoles = Get-AzureADServicePrincipal -SearchString “Office 365 SharePoint” | %{$_.AppRoles}
#Find the specific role
$appRole = AppRoles.Where({ $_.Value -eq "Sites.Manage.All" }
#You will also need to get the service principal for your function app
#Get the function app object id
$myfunctionapp = (Get-AzureADServicePrincipal -SearchString “myfunctionapp”).ObjectId
#assign the role to the MSI for the sharepoint resource
New-AzureADServiceAppRoleAssignment -ObjectId $myfunctionapp -PrincipalId $myfunctionapp -ResourceId $sharePoint -Id $appRole
然后,可以使用本地 MSI 终结点和机密来获取令牌。