gpt4 book ai didi

python - Python 中的 azure.ai.translation.document - 无法使用当前权限访问源文档位置

转载 作者:行者123 更新时间:2023-12-03 03:33:03 25 4
gpt4 key购买 nike

我在使用 Python 中的 azure.ai.translation.document 库时遇到问题。我已经在 Azure 中设置了翻译服务以及带有两个容器的 Blob 存储。我已使用“用户委托(delegate) key ”创建了 SAS 连接。一种用于源(读取/列表),一种用于目标(写入/列表)。
例如
enter image description here

我尝试运行 Python 程序,但源 blob 中的文件未转换并保存到目标 blob。

我收到此错误:azure.core.exceptions.HttpResponseError:(InvalidDocumentAccessLevel):无法使用当前权限访问源文档位置。

我使用了这个例子: https://learn.microsoft.com/en-us/azure/cognitive-services/translator/document-translation/client-sdks?tabs=python

import os from azure.core.credentials import AzureKeyCredential from azure.ai.translation.document import DocumentTranslationClient

key = "<your-key>" endpoint = "<your-custom-endpoint>" sourceUrl = "<your-container-sourceUrl>" targetUrl = "<your-container-targetUrl>"

client = DocumentTranslationClient(endpoint, AzureKeyCredential(key))

poller = client.begin_translation(sourceUrl, targetUrl, "fr")
result = poller.result()

print("Status: {}".format(poller.status()))
print("Created on: {}".format(poller.details.created_on))
print("Last updated on: {}".format(poller.details.last_updated_on))
print("Total number of translations on documents: {}".format(poller.details.documents_total_count))

print("\nOf total documents...")
print("{} failed".format(poller.details.documents_failed_count))
print("{} succeeded".format(poller.details.documents_succeeded_count))

for document in result:
print("Document ID: {}".format(document.id))
print("Document status: {}".format(document.status))
if document.status == "Succeeded":
print("Source document location: {}".format(document.source_document_url))
print("Translated document location: {}".format(document.translated_document_url))
print("Translated to language: {}\n".format(document.translated_to))
else:
print("Error Code: {}, Message: {}\n".format(document.error.code, document.error.message))

我在企业环境中的 Windows 中使用 Thonny(因为我仍在尝试学习 Python)。我们的云代理可能出了问题。

谢谢

洛兹

最佳答案

不要选择 HTTPS,而是选择 HTTPS 和 HTTP 选项,它应该可以工作。

关于python - Python 中的 azure.ai.translation.document - 无法使用当前权限访问源文档位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74303808/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com