如何使用Python Azure SDK和Graph修补现有应用程序?

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

我正在尝试以编程方式向Azure应用注册中添加Reply_url,但收到azure.graphrbac.models.graph_error_py3.GraphErrorException: Specified HTTP method is not allowed for the request target.

[当我尝试用新的reply_urls更新现有应用程序时失败。

我正在使用的SDK是:azure-graphrbac==0.61.1

我的代码:

from azure.common.credentials import ServicePrincipalCredentials
from azure.graphrbac import GraphRbacManagementClient
from azure.graphrbac.models import ApplicationUpdateParameters

class GraphClient:
    def __init__(self, client_id, client_secret, tenant_id, object_id):
        self._credentials = ServicePrincipalCredentials(
            client_id=client_id,
            secret=client_secret,
            tenant=tenant_id,
            resource="https://graph.windows.net"
        )
        self._graph_client = GraphRbacManagementClient(
            credentials=self._credentials,
            tenant_id=tenant_id
        )
        self._object_id = object_id
        self._application = self._graph_client.applications.get(self._object_id)

    def get_reply_urls(self) -> List[str]:
        return self._application.reply_urls

    def add_reply_url(self, reply_url) -> None:
        reply_urls: list = self.get_reply_urls()
        self._graph_client.applications.patch(
            self._object_id,
            ApplicationUpdateParameters(
                reply_urls=[
                    *reply_urls,
                    reply_url]
            )
        )
python azure azure-ad-graph-api
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.