Hi Santoshk,
At the time when you were writing this I still hadn't given async translation a try (translate files in blob). afterwards I gave it try following the instruction in this link:
https://learn.microsoft.com/en-us/azure/ai-services/translator/document-translation/how-to-guides/use-rest-api-programmatically?tabs=python
I did the following:
- I obtained the SASurl for both source and destination storage of both blob folders.
- I obtained the key for my azure account
- I changed the access policies of both source and destination blob storage (read/list for source, and write/list for destination) .
And used this script to run it :
import requests
base_path = '{your-document-translation-endpoint}/translator/document/batches'
key = '{your-api-key}'
route = '?api-version={date}'
constructed_url = base_path + route
payload= {
"inputs": [
{
"source": {
"sourceUrl": "https://YOUR-SOURCE-URL-WITH-READ-LIST-ACCESS-SAS",
"storageSource": "AzureBlob",
"language": "en"
},
"targets": [
{
"targetUrl": "https://YOUR-TARGET-URL-WITH-WRITE-LIST-ACCESS-SAS",
"storageSource": "AzureBlob",
"category": "general",
"language": "es"
}
]
}
]
}
headers = {
'Ocp-Apim-Subscription-Key': key,
'Content-Type': 'application/json'
}
response = requests.post(constructed_url, headers=headers, json=payload)
print(f'response status code: {response.status_code}\nresponse status: {response.reason}\nresponse headers: {response.headers}')
Results:
Output on command prompt:
response status code: 202
response status: Accepted
response headers: {'Transfer-Encoding': 'chunked', 'Content-Type': 'application/json; charset=utf-8', 'X-RequestId': '0c16fb2d-f966-420e-a515-3024255dd354', 'Operation-Location': 'https://translatefortaiwan.cognitiveservices.azure.com/translator/document/batches/7679bc6f-ae13-4b6a-9d41-8c1dd6986b56?api-version=2024-05-01', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains; preload', 'apim-request-id': '0c16fb2d-f966-420e-a515-3024255dd354', 'x-content-type-options': 'nosniff', 'x-ms-region': 'East Asia', 'Date': 'Wed, 18 Sep 2024 07:54:51 GMT'}
No file was translated and placed at the target folder.
Sam