zoukankan      html  css  js  c++  java
  • 【Azure 应用服务】azure function powershell 调用 New-AzADServicePrincipal -DisplayName $sp -PasswordCredential $spCred

    问题描述

    powershell 调用New-AzADServicePrincipal -DisplayName $sp -PasswordCredential $spCred,出现如下错误: Resource not found for the segment 'me'.

    Powershell 脚本为:

     # Login to China Azure
     $username="xxxxx@xxxx.partner.onmschina.cn"
     $password="xxxxxxxxxxxx"
     $pscredential = New-Object System.Management.Automation.PSCredential($username, $password)
     $tenantId=""
     $region="AzureChinaCloud"
    
    Connect
    -AzAccount -ServicePrincipal -Credential $pscredential -TenantId $tenantId -Environment $region $azContext = Set-AzContext -SubscriptionId "" -Tenant "" $credentials = New-Object -TypeName Microsoft.Azure.Commands.ActiveDirectory.PSADPasswordCredential -Property @{StartDate=Get-Date; EndDate=Get-Date -Year 2024; Password='StrongPassworld!23'} $sp = New-AzAdServicePrincipal -DisplayName ServicePrincipalName -PasswordCredential $credentials

    问题分析

    在云上遇见问题后,可以反向在本地测试运行,看是否能遇见相同的问题。从错误消息可以定位到是否当前所登录账号的权限问题,可以用下面的步骤来检查或赋予权限:

    第一步:在Azure Active Directory中选择应用注册,然后选择角色和管理员,点击“在需要时,使用PIM实时访问角色,详细了解PIM

    第二步:选择AzureAD角色

     

    第三步:点击分配资格

    第四步:选择角色,点击添加分配

    第五步:选择角色,选择成员,输入应用的名称或者clientid点击选择,点击下一步。

    第六步:保存分配成功,即可在Azure Active Directory中的角色和管理员中找到该角色点击分配中查看到应用

    参考资料

    PIM(Privileged Identity Management)分配https://docs.azure.cn/zh-cn/active-directory/privileged-identity-management/groups-assign-member-owner?view=azs-2102

    应用程序管理员https://docs.azure.cn/zh-cn/active-directory/roles/permissions-reference?view=azs-2102#application-administrator

    当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!

  • 相关阅读:
    python编码问题和py2和py3的不同
    day27
    多继承补充
    zoj3820 Building Fire Stations 树的中心
    DLX舞蹈链 hdu5046
    时间复杂度
    线性求中位数 poj2388
    codeforce447 D SGU 548 贪心+优先队列
    hdu4864 hdu4268 贪心 lower_bound
    zoj3672 Gao The Sequence
  • 原文地址:https://www.cnblogs.com/lulight/p/15220943.html
Copyright © 2011-2022 走看看