首页 > 解决方案 > Azure Functions - 如何使用 API 连接连接到其他服务

问题描述

我是 azure 函数的新手,我想在函数应用程序中部署我的 python 代码,我的代码与 SharePoint、Outlook、SQL Server 链接,有人可以建议我在 azure 函数应用程序中连接所有这三个函数的最佳方法吗....#python #sql #sharepoint #azure

标签: pythonazuresharepointazure-functions

解决方案


首先,想讨论一下从 Azure 函数访问 SharePoint 文件,我们只需要从 VSCode 使用少量导入,我们还有 Office365-Rest-Client 的 python 文档。

以下是从 SharePoint 下载文件的示例之一:

Import os
import tempfile


from office365.sharepoint.client_context import ClientContext
from tests import test_team_site_url, test_client_credentials


ctx = ClientContext(test_team_site_url).with_credentials(test_client_credentials)
# file_url = '/sites/team/Shared Documents/big_buck_bunny.mp4'
file_url = "/sites/team/Shared Documents/report #123.csv"
download_path = os.path.join(tempfile.mkdtemp(), os.path.basename(file_url))
with open(download_path, "wb") as local_file:
    file = ctx.web.get_file_by_server_relative_path(file_url).download(local_file).execute_query()
print("[Ok] file has been downloaded into: {0}".format(download_path))

要获取文件夹及其操作的所有详细信息,请参阅此GIT 链接

为了连接到 SQL,我们有一个博客,其中包含 Python 代码的所有见解,这要感谢lieben。


推荐阅读