Skip to content

Commit 222ba44

Browse files
authored
modify permission (#22960)
1 parent 0376028 commit 222ba44

File tree

8 files changed

+34
-15
lines changed

8 files changed

+34
-15
lines changed

sdk/translation/Azure.AI.Translation.Document/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ var client = new DocumentTranslationClient(new Uri(endpoint), new DefaultAzureCr
103103
```
104104

105105
## Key concepts
106+
The Document Translation service requires that you upload your files to an Azure Blob Storage source container and provide
107+
a target container where the translated documents can be written. SAS tokens to the containers (or files) are used to
108+
access the documents and create the translated documents in the target container. Additional information about setting this up can be found in
109+
the service documentation:
110+
111+
- [Set up Azure Blob Storage containers][source_containers] with your documents.
112+
- Optionally apply [glossaries][glossary] or a [custom model for translation][custom_model].
113+
- Generate [SAS tokens][sas_token] to your containers (or files) with the appropriate [permissions][sas_token_permissions].
106114

107115
### DocumentTranslationClient
108116
A `DocumentTranslationClient` is the primary interface for developers using the Document Translation client library. It provides both synchronous and asynchronous methods to perform the following operations:
@@ -448,6 +456,11 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con
448456
[azure_portal_create_DT_resource]: https://ms.portal.azure.com/#create/Microsoft.CognitiveServicesTextTranslation
449457
[cognitive_resource_cli]: https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account-cli
450458
[dotnet_lro_guidelines]: https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-longrunning
459+
[source_containers]: https://docs.microsoft.com/azure/cognitive-services/translator/document-translation/get-started-with-document-translation?tabs=csharp#create-your-azure-blob-storage-containers
460+
[custom_model]: https://docs.microsoft.com/azure/cognitive-services/translator/custom-translator/quickstart-build-deploy-custom-model
461+
[glossary]: https://docs.microsoft.com/azure/cognitive-services/translator/document-translation/overview#supported-glossary-formats
462+
[sas_token]: https://docs.microsoft.com/azure/cognitive-services/translator/document-translation/create-sas-tokens?tabs=Containers#create-your-sas-tokens-with-azure-storage-explorer
463+
[sas_token_permissions]: https://aka.ms/azsdk/documenttranslation/sas-permissions
451464

452465
[documenttranslation_client_class]: https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/translation/Azure.AI.Translation.Document/src/DocumentTranslationClient.cs
453466
[azure_identity]: https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/identity/Azure.Identity/README.md

sdk/translation/Azure.AI.Translation.Document/samples/Sample1_StartTranslation.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ To Start a translation operation for a single document or documents in a single
1919

2020
To call `StartTranslationAsync` you need to initialize an object of type `DocumentTranslationInput` which contains the information needed to translate the documents.
2121

22-
- The `sourceUri` is a SAS URI with read access for the document to be translated or read and list access for the blob container holding the documents to be translated.
23-
- The `targetUri` is a SAS URI with read and write access for the blob container to which the translated documents will be written.
24-
25-
More on generating SAS Tokens [here](https://docs.microsoft.com/azure/cognitive-services/translator/document-translation/get-started-with-document-translation?tabs=csharp#create-sas-access-tokens-for-document-translation)
22+
> The `sourceUri` and the `targetUri` are SAS URI with permissions that allow the service to access the content on the container/blob.
23+
See the [service documentation][Sas_token_permissions] for the supported SAS permissions.
2624

2725
```C# Snippet:StartTranslationAsync
2826
Uri sourceUri = new Uri("<source SAS URI>");
@@ -66,5 +64,6 @@ To see the full example source files, see:
6664
* [Synchronously StartTranslation ](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/translation/Azure.AI.Translation.Document/tests/samples/Sample_StartTranslation.cs)
6765
* [Asynchronously StartTranslation ](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/translation/Azure.AI.Translation.Document/tests/samples/Sample_StartTranslationAsync.cs)
6866

67+
[Sas_token_permissions]: https://aka.ms/azsdk/documenttranslation/sas-permissions
6968
[DefaultAzureCredential]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/README.md
7069
[README]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/translation/Azure.AI.Translation.Document/README.md

sdk/translation/Azure.AI.Translation.Document/samples/Sample4_MultipleInputs.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ To Start a translation operation for documents in multiple blob containers, call
1919

2020
To call `StartTranslationAsync` you need to initialize a list of `DocumentTranslationInput` which contains the information needed to translate the documents. Each `DocumentTranslationInput` contains a source container and a list of target containers. The `AddTarget` method is used to add targets to the input.
2121

22-
- The `sourceUri` is a SAS URI with read access for the document to be translated or read and list access for the blob container holding the documents to be translated.
23-
- The `targetUri` is a SAS URI with read and write access for the blob container to which the translated documents will be written.
24-
25-
More on generating SAS Tokens [here](https://docs.microsoft.com/azure/cognitive-services/translator/document-translation/get-started-with-document-translation?tabs=csharp#create-sas-access-tokens-for-document-translation)
22+
> The `sourceUri` and the `targetUri` are SAS URI with permissions that allow the service to access the content on the container/blob.
23+
See the [service documentation][Sas_token_permissions] for the supported SAS permissions.
2624

2725
```C# Snippet:MultipleInputsAsync
2826
Uri source1SasUriUri = new Uri("<source1 SAS URI>");
@@ -74,5 +72,6 @@ To see the full example source files, see:
7472
* [Synchronously MultipleInputs ](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/translation/Azure.AI.Translation.Document/tests/samples/Sample_MultipleInputs.cs)
7573
* [Asynchronously MultipleInputs ](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/translation/Azure.AI.Translation.Document/tests/samples/Sample_MultipleInputsAsync.cs)
7674

75+
[Sas_token_permissions]: https://aka.ms/azsdk/documenttranslation/sas-permissions
7776
[DefaultAzureCredential]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/README.md
7877
[README]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/translation/Azure.AI.Translation.Document/README.md

sdk/translation/Azure.AI.Translation.Document/src/DocumentTranslationInput.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ public partial class DocumentTranslationInput
1919
/// <summary>
2020
/// Initializes a new instance of <see cref="DocumentTranslationInput"/>.
2121
/// </summary>
22-
/// <param name="sourceUri">The SAS URI for the source container containing documents to be translated. Read and List permissions are needed.</param>
23-
/// <param name="targetUri">The SAS URI for the target container to which the translated documents will be written. Read and Write permissions are needed.</param>
22+
/// <param name="sourceUri">The SAS URI for the source container containing documents to be translated.
23+
/// See the service documentation for the supported SAS permissions for accessing
24+
/// source storage containers/blobs: <a href="https://aka.ms/azsdk/documenttranslation/sas-permissions"/>.</param>
25+
/// <param name="targetUri">The SAS URI for the target container to which the translated documents will be written.
26+
/// See the service documentation for the supported SAS permissions for accessing
27+
/// target storage containers/blobs: <a href="https://aka.ms/azsdk/documenttranslation/sas-permissions"/>.</param>
2428
/// <param name="targetLanguageCode">Language code to translate documents to. For supported languages see
2529
/// <a href="https://docs.microsoft.com/azure/cognitive-services/translator/language-support#translate"/>.</param>
2630
/// <param name="glossary">Custom <see cref="TranslationGlossary"/> to be used in the translation operation. For supported file types see
@@ -39,7 +43,9 @@ public DocumentTranslationInput(Uri sourceUri, Uri targetUri, string targetLangu
3943
/// <summary>
4044
/// Add a <see cref="TranslationTarget"/> to the translation input.
4145
/// </summary>
42-
/// <param name="targetUri">The SAS URI for the target container to which the translated documents will be written. Read and Write permissions are needed.</param>
46+
/// <param name="targetUri">The SAS URI for the target container to which the translated documents will be written.
47+
/// See the service documentation for the supported SAS permissions for accessing
48+
/// target storage containers/blobs: <a href="https://aka.ms/azsdk/documenttranslation/sas-permissions"/>.</param>
4349
/// <param name="languageCode">Language code to translate documents to. For supported languages see
4450
/// <a href="https://docs.microsoft.com/azure/cognitive-services/translator/language-support#translate"/>.</param>
4551
/// <param name="glossary">Custom <see cref="TranslationGlossary"/> to be used in the translation operation. For supported file types see

sdk/translation/Azure.AI.Translation.Document/src/TranslationSource.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ public partial class TranslationSource
1414

1515
/// <summary>
1616
/// Location of the folder / container or single file with your documents.
17-
/// This should be a SAS Uri.
17+
/// See the service documentation for the supported SAS permissions for accessing
18+
/// source storage containers/blobs: <a href="https://aka.ms/azsdk/documenttranslation/sas-permissions"/>.
1819
/// </summary>
1920
[CodeGenMember("SourceUrl")]
2021
public Uri SourceUri { get; }

sdk/translation/Azure.AI.Translation.Document/src/TranslationTarget.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ public partial class TranslationTarget
1414

1515
/// <summary>
1616
/// Location of the container with your documents.
17-
/// This should be a SAS Uri.
17+
/// See the service documentation for the supported SAS permissions for accessing
18+
/// target storage containers/blobs: <a href="https://aka.ms/azsdk/documenttranslation/sas-permissions"/>.
1819
/// </summary>
1920
[CodeGenMember("TargetUrl")]
2021
public Uri TargetUri { get; }

sdk/translation/Azure.AI.Translation.Document/tests/Infrastructure/DocumentTranslationLiveTestBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public async Task<Uri> CreateTargetContainerAsync(List<TestDocument> documents =
9191
}
9292

9393
var expiresOn = DateTimeOffset.UtcNow.AddHours(1);
94-
return containerClient.GenerateSasUri(BlobContainerSasPermissions.Read | BlobContainerSasPermissions.Write, expiresOn);
94+
return containerClient.GenerateSasUri(BlobContainerSasPermissions.List | BlobContainerSasPermissions.Write, expiresOn);
9595
}
9696

9797
private async Task UploadDocumentsAsync(BlobContainerClient containerClient, List<TestDocument> documents)

sdk/translation/Azure.AI.Translation.Document/tests/samples/Sample_StartTranslationWithAzureBlob.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ This sample demonstrates how to use Azure Blob Storage to set up the necessary r
8181

8282
// Generate SAS tokens for source & target
8383
Uri srcSasUri = sourceContainerClient.GenerateSasUri(BlobContainerSasPermissions.List | BlobContainerSasPermissions.Read, DateTime.UtcNow.AddMinutes(30));
84-
Uri tgtSasUri = targetContainerClient.GenerateSasUri(BlobContainerSasPermissions.Read | BlobContainerSasPermissions.Write | BlobContainerSasPermissions.Delete, DateTime.UtcNow.AddMinutes(30));
84+
Uri tgtSasUri = targetContainerClient.GenerateSasUri(BlobContainerSasPermissions.List | BlobContainerSasPermissions.Write | BlobContainerSasPermissions.Delete, DateTime.UtcNow.AddMinutes(30));
8585

8686
// Submit the translation operation and wait for it to finish
8787
var operationRequest = new DocumentTranslationInput(srcSasUri, tgtSasUri, "es");

0 commit comments

Comments
 (0)