You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python中使用Azure SDK无法导入ApplicationsRequestBuilder方法的问题

解决ApplicationsRequestBuilder导入问题

正确导入方式

ApplicationsRequestBuilder位于msgraph.generated.applications.applications_request_builder模块中,需添加以下导入语句:

from msgraph.generated.applications.applications_request_builder import ApplicationsRequestBuilder

更新后的完整导入代码

将上述语句加入现有导入列表,最终导入代码如下:

import pyodbc
import adal
import struct
import json  
import subprocess 
import asyncio 
from azure.identity import ClientSecretCredential, DefaultAzureCredential
from azure.keyvault.secrets import SecretClient
from msgraph import GraphServiceClient
from msgraph.generated.models.password_credential import PasswordCredential
from msgraph.generated.applications.item.add_password.add_password_post_request_body import AddPasswordPostRequestBody
from msgraph.generated.applications.applications_request_builder import ApplicationsRequestBuilder

补充说明

  • 确保msgraph-sdk-python为最新版本,旧版本模块结构可能存在差异,执行pip install --upgrade msgraph-sdk-python完成版本更新。
  • 代码中获取应用后的调用存在逻辑问题:by_application_id接收的是应用的client_id,若要通过目录对象ID获取应用,应替换为by_directory_object_id(app.id)。

内容的提问来源于stack exchange,提问作者gjgjgjgj14

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 23:08:27