@Eduardo Gomez Apologies, I wasn't working yesterday. I got a chance to run your code today and found the issue for the error. From debugging the code, I found that you are setting the targetURI
by calling SaveFromdAzureBlobStorage()
but this method is actually uploading the original file to the translated container even before the translation request is called. Hence, the error "File already exists".
All I had to do was comment out these lines from the method SaveFromdAzureBlobStorage()
to translate a document successfully.
//var blob = ContainerClient.GetBlobClient(Path.GetFileName(FilePath));
//await blob.UploadAsync(FilePath, true);
Once this is done the file I uploaded was successfully translated and uploaded. You can check the file Invoice_1.pdf
in both your containers for reference.
Since you have some additional files in the translated container the requests for these documents will still error out since I have not deleted these documents from your previous tests in the translated container. Please try to cleanup your containers and try again. I also think you can factor your code to only pass the uploaded file instead of translating all the documents in a container again whenever a user provides a document. If this is not changed every request will try to translate each and every document from original container and the documents that are already present in translated container will again error out.
Content of my translated document in spanish.
P.S: Please refresh your resource keys to ensure the same is not misused. Thanks!!
If an answer is helpful, please click on or upvote which might help other community members reading this thread.