diff --git a/sdk/translation/azure-ai-translation-document/assets.json b/sdk/translation/azure-ai-translation-document/assets.json index 45f46d5d70e5..cda670f2d9e0 100644 --- a/sdk/translation/azure-ai-translation-document/assets.json +++ b/sdk/translation/azure-ai-translation-document/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/translation/azure-ai-translation-document", - "Tag": "python/translation/azure-ai-translation-document_cf5e8aa525" + "Tag": "python/translation/azure-ai-translation-document_c043fc2ede" } diff --git a/sdk/translation/azure-ai-translation-document/tests/asynctestcase.py b/sdk/translation/azure-ai-translation-document/tests/asynctestcase.py index 2df5d51cf8cb..d3689fb2758c 100644 --- a/sdk/translation/azure-ai-translation-document/tests/asynctestcase.py +++ b/sdk/translation/azure-ai-translation-document/tests/asynctestcase.py @@ -3,6 +3,7 @@ # Licensed under the MIT License. # ------------------------------------ +from azure.ai.translation.document.models import BatchRequest, SourceInput, StartTranslationDetails from devtools_testutils import AzureRecordedTestCase from testcase import DocumentTranslationTest, Document from azure.ai.translation.document import DocumentTranslationInput, TranslationTarget @@ -104,3 +105,39 @@ async def _begin_and_validate_translation_with_multiple_docs_async(self, async_c # validate self._validate_translation_metadata(poller=poller) return poller + + async def _prepare_and_validate_start_translation_details_async(self, async_client, docs_count, **kwargs): + # get input params + wait_for_operation = kwargs.pop("wait", False) + variables = kwargs.get("variables", {}) + language = kwargs.pop("language", "es") + + # prepare test data + blob_data = Document.create_dummy_docs(docs_count=docs_count) + source_input = SourceInput( + source_url=self.create_source_container(data=blob_data, variables=variables) + ) + target = TranslationTarget( + target_url=self.create_target_container(variables=variables), + language=language + ) + batch_request = BatchRequest( + source=source_input, + targets=[target] + ) + start_translation_details = StartTranslationDetails( + inputs=[batch_request] + ) + + # submit job + poller = await async_client.begin_translation(start_translation_details) + assert poller.id is not None + # wait for result + if wait_for_operation: + result = await poller.result() + async for doc in result: + self._validate_doc_status(doc, "es") + + # validate + self._validate_translation_metadata(poller=poller) + return poller diff --git a/sdk/translation/azure-ai-translation-document/tests/conftest.py b/sdk/translation/azure-ai-translation-document/tests/conftest.py index a5f58839ffdb..d354b0cef3e1 100644 --- a/sdk/translation/azure-ai-translation-document/tests/conftest.py +++ b/sdk/translation/azure-ai-translation-document/tests/conftest.py @@ -15,6 +15,7 @@ add_general_regex_sanitizer, add_oauth_response_sanitizer, remove_batch_sanitizers, + set_custom_default_matcher, ) from azure.storage.blob import BlobServiceClient @@ -27,22 +28,10 @@ def add_sanitizers(test_proxy): regex="(?<=\\/\\/)[a-z]+(?=(?:|-secondary)\\.(?:table|blob|queue)\\.core\\.windows\\.net)", value="fakeendpoint", ) + set_custom_default_matcher(ignored_headers="Accept-Encoding") add_oauth_response_sanitizer() # Remove the following sanitizers since certain fields are needed in tests and are non-sensitive: # - AZSDK3430: $..id # - AZSDK3424: $..to - remove_batch_sanitizers(["AZSDK3430", "AZSDK3424"]) - - # run tests - yield - - # Dogfood env uses a static storage account so we clean up the blob resources - # This is unnecessary for AzureCloud where each storage account is deleted at the end of testing - if is_live() and os.getenv("TRANSLATION_ENVIRONMENT") == "Dogfood": - client = BlobServiceClient( - "https://" + os.getenv("TRANSLATION_DOCUMENT_STORAGE_NAME") + ".blob.core.windows.net/", - os.getenv("TRANSLATION_DOCUMENT_STORAGE_KEY"), - ) - for container in client.list_containers(): - client.delete_container(container) + remove_batch_sanitizers(["AZSDK3430", "AZSDK3424", "AZSDK4001"]) diff --git a/sdk/translation/azure-ai-translation-document/tests/perfstress_tests/README.md b/sdk/translation/azure-ai-translation-document/tests/perfstress_tests/README.md index fcfcc9a01aa5..215103646004 100644 --- a/sdk/translation/azure-ai-translation-document/tests/perfstress_tests/README.md +++ b/sdk/translation/azure-ai-translation-document/tests/perfstress_tests/README.md @@ -8,9 +8,9 @@ Start by creating a new virtual environment for your perf tests. This will need The following environment variable will need to be set for the tests to access the live resources: ``` -TRANSLATION_DOCUMENT_TEST_ENDPOINT= -TRANSLATION_DOCUMENT_STORAGE_NAME= -TRANSLATION_DOCUMENT_STORAGE_KEY= +DOCUMENT_TRANSLATION_ENDPOINT= +DOCUMENT_TRANSLATION_STORAGE_NAME= +DOCUMENT_TRANSLATION_STORAGE_KEY= ``` ### Setup for perf test runs diff --git a/sdk/translation/azure-ai-translation-document/tests/perfstress_tests/perf_translation.py b/sdk/translation/azure-ai-translation-document/tests/perfstress_tests/perf_translation.py index fe009faf420d..98aca69eda90 100644 --- a/sdk/translation/azure-ai-translation-document/tests/perfstress_tests/perf_translation.py +++ b/sdk/translation/azure-ai-translation-document/tests/perfstress_tests/perf_translation.py @@ -35,9 +35,9 @@ def __init__(self, arguments): super().__init__(arguments) # test related env vars - endpoint = os.environ["TRANSLATION_DOCUMENT_TEST_ENDPOINT"] - self.storage_name = os.environ["TRANSLATION_DOCUMENT_STORAGE_NAME"] - self.storage_key = os.environ["TRANSLATION_DOCUMENT_STORAGE_KEY"] + endpoint = os.environ["DOCUMENT_TRANSLATION_ENDPOINT"] + self.storage_name = os.environ["DOCUMENT_TRANSLATION_STORAGE_NAME"] + self.storage_key = os.environ["DOCUMENT_TRANSLATION_STORAGE_KEY"] self.storage_endpoint = "https://" + self.storage_name + ".blob.core.windows.net/" self.source_container_name = "source-perf-" + str(uuid.uuid4()) self.target_container_name = "target-perf-" + str(uuid.uuid4()) diff --git a/sdk/translation/azure-ai-translation-document/tests/preparer.py b/sdk/translation/azure-ai-translation-document/tests/preparer.py index a8abc3810b09..e07fdf5fddae 100644 --- a/sdk/translation/azure-ai-translation-document/tests/preparer.py +++ b/sdk/translation/azure-ai-translation-document/tests/preparer.py @@ -12,10 +12,9 @@ DocumentTranslationPreparer = functools.partial( PowerShellPreparer, "translation", - translation_document_test_endpoint="https://fakeendpoint.cognitiveservices.azure.com", - translation_document_name="redacted", - translation_document_storage_name="redacted", - translation_document_storage_key="fakeZmFrZV9hY29jdW50X2tleQ==", + document_translation_endpoint="https://fakeendpoint.cognitiveservices.azure.com", + document_translation_storage_name="fakeendpoint", + document_translation_storage_key="fakeZmFrZV9hY29jdW50X2tleQ==", ) @@ -26,7 +25,7 @@ def __init__(self, client_cls, client_kwargs={}, **kwargs): self.client_cls = client_cls def create_resource(self, name, **kwargs): - doctranslation_test_endpoint = kwargs.get("translation_document_test_endpoint") + doctranslation_test_endpoint = kwargs.get("document_translation_endpoint") # set polling interval to 0 for recorded tests if not self.is_live: diff --git a/sdk/translation/azure-ai-translation-document/tests/test_model_updates.py b/sdk/translation/azure-ai-translation-document/tests/test_model_updates.py new file mode 100644 index 000000000000..23889f4705ac --- /dev/null +++ b/sdk/translation/azure-ai-translation-document/tests/test_model_updates.py @@ -0,0 +1,261 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ + +import datetime +import functools +from azure.ai.translation.document.models import DocumentStatus, FileFormatType, StatusSummary, TranslationGlossary, TranslationStatus +from testcase import DocumentTranslationTest +from preparer import ( + DocumentTranslationPreparer, + DocumentTranslationClientPreparer as _DocumentTranslationClientPreparer, +) +from devtools_testutils import recorded_by_proxy +from azure.ai.translation.document import DocumentTranslationClient, DocumentTranslationInput, TranslationTarget + +DocumentTranslationClientPreparer = functools.partial(_DocumentTranslationClientPreparer, DocumentTranslationClient) + +class TestModelUpdates(DocumentTranslationTest): + @DocumentTranslationPreparer() + @DocumentTranslationClientPreparer() + @recorded_by_proxy + def test_start_translation_details_model(self, **kwargs): + client = kwargs.pop("client") + variables = kwargs.pop("variables", {}) + + docs_count = 2 + self._prepare_and_validate_start_translation_details(client, docs_count, wait=False, variables=variables) + return variables + + @DocumentTranslationPreparer() + @DocumentTranslationClientPreparer() + @recorded_by_proxy + def test_document_translation_input_args(self, **kwargs): + # Creating an instance using required positional arguments + source_container_url = "https://t7d8641d8f25ec940prim.blob.core.windows.net/source-12345" + target_container_url = "https://t7d8641d8f25ec940prim.blob.core.windows.net/target-67890" + doc_input_positional = DocumentTranslationInput( + source_url=source_container_url, + targets=[TranslationTarget(target_url=target_container_url, language="fr")] + ) + assert doc_input_positional is not None + assert doc_input_positional.source_url is not None + assert doc_input_positional.targets and doc_input_positional.targets[0].target_url and doc_input_positional.targets[0].language is not None + + # Using keyword-only arguments to specify additional optional parameters + doc_input_keyword = DocumentTranslationInput( + source_container_url, + [TranslationTarget(target_url=target_container_url, language="fr")], + source_language="en", + storage_type="FOLDER", + storage_source="AzureBlob", + prefix="start_", + suffix="_end" + ) + self.validate_document_translation(doc_input_keyword) + + # Creating an instance using a dictionary to pass parameters + params = { + "source_url": source_container_url, + "targets": [TranslationTarget(target_url=target_container_url, language="fr")], + "source_language": "en", + "storage_type": "FOLDER", + "storage_source": "AzureBlob", + "prefix": "start_", + "suffix": "_end" + } + doc_input_dict = DocumentTranslationInput(**params) + self.validate_document_translation(doc_input_dict) + + @DocumentTranslationPreparer() + @DocumentTranslationClientPreparer() + @recorded_by_proxy + def test_translation_target_args(self, **kwargs): + # Creating an instance using required positional arguments + target_positional = TranslationTarget( + target_url="https://t7d8641d8f25ec940prim.blob.core.windows.net/target-67890", + language="es" + ) + assert target_positional is not None + assert target_positional.target_url is not None + assert target_positional.language is not None + + # Using keyword arguments to specify additional optional parameters + target_keyword = TranslationTarget( + target_url="https://t7d8641d8f25ec940prim.blob.core.windows.net/target-67890", + language="es", + category_id="general", + glossaries=[TranslationGlossary(glossary_url="https://glossaryfile.txt", file_format="txt")], + storage_source="AzureBlob" + ) + self.validate_translation_target(target_keyword) + + # Creating an instance using a dictionary to pass parameters + params = { + "target_url": "https://t7d8641d8f25ec940prim.blob.core.windows.net/target-67890", + "language": "es", + "category_id": "general", + "glossaries": [TranslationGlossary(glossary_url="https://glossaryfile.txt", file_format="txt")], + "storage_source": "AzureBlob" + } + target_dict = TranslationTarget(**params) + self.validate_translation_target(target_dict) + + @DocumentTranslationPreparer() + @DocumentTranslationClientPreparer() + @recorded_by_proxy + def test_translation_glossary_args(self, **kwargs): + # Creating an instance using required positional arguments + glossary_positional = TranslationGlossary( + glossary_url="https://glossaryfile.txt", + file_format="txt" + ) + assert glossary_positional is not None + assert glossary_positional.glossary_url is not None + assert glossary_positional.file_format is not None + + # Using keyword arguments to specify additional optional parameters + glossary_keyword = TranslationGlossary( + glossary_url="https://glossaryfile.txt", + file_format="txt", + format_version="1.0", + storage_source="AzureBlob" + ) + self.validate_translation_glossary(glossary_keyword) + + # Creating an instance using a dictionary to pass parameters + params = { + "glossary_url": "https://glossaryfile.txt", + "file_format": "txt", + "format_version": "1.0", + "storage_source": "AzureBlob" + } + glossary_dict = TranslationGlossary(**params) + self.validate_translation_glossary(glossary_dict) + + @DocumentTranslationPreparer() + @DocumentTranslationClientPreparer() + @recorded_by_proxy + def test_document_status_args(self, **kwargs): + # Using keyword arguments to specify additional optional parameters + document_status_keyword = DocumentStatus( + source_document_url="https://t7d8641d8f25ec940prim.blob.core.windows.net/source-12345/document.txt", + created_on=datetime.datetime.now(), + last_updated_on=datetime.datetime.now(), + status="Running", + translated_to="es", + translation_progress=0.5, + id="fd57e619-d7b2-48b7-81cf-24b76e002a8f", + translated_document_url="https://t7d8641d8f25ec940prim.blob.core.windows.net/target-67890/document.txt", + error=None, + characters_charged=1000 + ) + self.validate_document_status(document_status_keyword) + + # Creating an instance using a dictionary to pass parameters + params = { + "source_document_url": "https://t7d8641d8f25ec940prim.blob.core.windows.net/source-12345/document.txt", + "created_on": datetime.datetime.now(), + "last_updated_on": datetime.datetime.now(), + "status": "Succeeded", + "translated_to": "fr", + "translation_progress": 1.0, + "id": "fd57e619-d7b2-48b7-81cf-24b76e002a8f", + "translated_document_url": "https://t7d8641d8f25ec940prim.blob.core.windows.net/target-67890/document.txt", + "error": None, + "characters_charged": 2000 + } + document_status_dict = DocumentStatus(**params) + self.validate_document_status(document_status_dict) + + @DocumentTranslationPreparer() + @DocumentTranslationClientPreparer() + @recorded_by_proxy + def test_translation_status_args(self, **kwargs): + # Using keyword-only arguments to specify additional optional parameters + status_summary = StatusSummary( + total=10, + failed=2, + success=5, + in_progress=3, # Note the naming matches the class definition + not_yet_started=0, + canceled=0, + total_characters_charged=10000 + ) + translation_status_keyword = TranslationStatus( + id="fd57e619-d7b2-48b7-81cf-24b76e002a8f", + created_on=datetime.datetime.now(), + last_updated_on=datetime.datetime.now(), + status="Succeeded", + summary=status_summary, + error=None + ) + self.validate_translation_status(translation_status_keyword) + + # Creating an instance using a dictionary to pass parameters + params = { + "id": "fd57e619-d7b2-48b7-81cf-24b76e002a8f", + "created_on": datetime.datetime.now(), + "last_updated_on": datetime.datetime.now(), + "status": "Succeeded", + "summary": status_summary, + "error": None + } + translation_status_dict = TranslationStatus(**params) + self.validate_translation_status(translation_status_dict) + + def validate_translation_target(self, translation_target): + assert translation_target is not None + assert translation_target.target_url is not None + assert translation_target.language is not None + assert translation_target.category_id is not None + assert translation_target.glossaries and translation_target.glossaries[0].glossary_url and translation_target.glossaries[0].file_format is not None + assert translation_target.storage_source is not None + + def validate_document_translation(self, document_translation): + assert document_translation is not None + assert document_translation.source_url is not None + assert document_translation.targets and document_translation.targets[0].target_url and document_translation.targets[0].language is not None + assert document_translation.source_language is not None + assert document_translation.storage_type is not None + assert document_translation.storage_source is not None + assert document_translation.prefix is not None + assert document_translation.suffix is not None + + def validate_translation_glossary(self, translation_glossary): + assert translation_glossary is not None + assert translation_glossary.glossary_url is not None + assert translation_glossary.file_format is not None + assert translation_glossary.format_version is not None + assert translation_glossary.storage_source is not None + + def validate_document_status(self, document_status): + assert document_status is not None + assert document_status.source_document_url is not None + assert document_status.created_on is not None + assert document_status.last_updated_on is not None + assert document_status.status is not None + assert document_status.translated_to is not None + assert document_status.translation_progress is not None + assert document_status.id is not None + assert document_status.translated_document_url is not None + assert document_status.characters_charged is not None + + def validate_translation_status(self, translation_status): + assert translation_status is not None + assert translation_status.id is not None + assert translation_status.created_on is not None + assert translation_status.last_updated_on is not None + assert translation_status.status is not None + assert translation_status.summary is not None + + # verifying old attributes + assert translation_status is not None + assert translation_status.documents_total_count is not None + assert translation_status.documents_failed_count is not None + assert translation_status.documents_in_progress_count is not None + assert translation_status.documents_succeeded_count is not None + assert translation_status.documents_not_started_count is not None + assert translation_status.documents_canceled_count is not None + assert translation_status.total_characters_charged is not None diff --git a/sdk/translation/azure-ai-translation-document/tests/test_model_updates_async.py b/sdk/translation/azure-ai-translation-document/tests/test_model_updates_async.py new file mode 100644 index 000000000000..2a8632f7af55 --- /dev/null +++ b/sdk/translation/azure-ai-translation-document/tests/test_model_updates_async.py @@ -0,0 +1,29 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ + +import functools +from asynctestcase import AsyncDocumentTranslationTest +from azure.ai.translation.document.models import FileFormatType +from preparer import ( + DocumentTranslationPreparer, + DocumentTranslationClientPreparer as _DocumentTranslationClientPreparer, +) +from devtools_testutils.aio import recorded_by_proxy_async +from azure.ai.translation.document.aio import DocumentTranslationClient + +DocumentTranslationClientPreparer = functools.partial(_DocumentTranslationClientPreparer, DocumentTranslationClient) + +class TestModelUpdates(AsyncDocumentTranslationTest): + @DocumentTranslationPreparer() + @DocumentTranslationClientPreparer() + @recorded_by_proxy_async + async def test_start_translation_details_model(self, **kwargs): + client = kwargs.pop("client") + variables = kwargs.pop("variables", {}) + + docs_count = 2 + await self._prepare_and_validate_start_translation_details_async(client, docs_count, wait=False, variables=variables) + return variables + diff --git a/sdk/translation/azure-ai-translation-document/tests/testcase.py b/sdk/translation/azure-ai-translation-document/tests/testcase.py index 6eb5cb0b3fc7..600b8c64b4b3 100644 --- a/sdk/translation/azure-ai-translation-document/tests/testcase.py +++ b/sdk/translation/azure-ai-translation-document/tests/testcase.py @@ -7,6 +7,7 @@ import time import datetime import uuid +from azure.ai.translation.document.models import BatchRequest, SourceInput, StartTranslationDetails from devtools_testutils import AzureRecordedTestCase, set_custom_default_matcher from azure.storage.blob import generate_container_sas, ContainerClient from azure.ai.translation.document import DocumentTranslationInput, TranslationTarget @@ -32,7 +33,7 @@ def create_dummy_docs(cls, docs_count): class DocumentTranslationTest(AzureRecordedTestCase): @property def storage_name(self): - return os.getenv("TRANSLATION_DOCUMENT_STORAGE_NAME", "redacted") + return os.getenv("DOCUMENT_TRANSLATION_STORAGE_NAME", "redacted") @property def storage_endpoint(self): @@ -40,7 +41,7 @@ def storage_endpoint(self): @property def storage_key(self): - return os.getenv("TRANSLATION_DOCUMENT_STORAGE_KEY", "fakeZmFrZV9hY29jdW50X2tleQ==") + return os.getenv("DOCUMENT_TRANSLATION_STORAGE_KEY", "fakeZmFrZV9hY29jdW50X2tleQ==") def upload_documents(self, data, container_client): if isinstance(data, list): @@ -301,3 +302,39 @@ def _begin_and_validate_translation_with_multiple_docs(self, client, docs_count, self._validate_translation_metadata(poller=poller) return poller + + def _prepare_and_validate_start_translation_details(self, client, docs_count, **kwargs): + # get input params + wait_for_operation = kwargs.pop("wait", False) + variables = kwargs.get("variables", {}) + language = kwargs.pop("language", "es") + + # prepare test data + blob_data = Document.create_dummy_docs(docs_count=docs_count) + source_input = SourceInput( + source_url=self.create_source_container(data=blob_data, variables=variables) + ) + target = TranslationTarget( + target_url=self.create_target_container(variables=variables), + language=language + ) + batch_request = BatchRequest( + source=source_input, + targets=[target] + ) + start_translation_details = StartTranslationDetails( + inputs=[batch_request] + ) + + # submit job + poller = client.begin_translation(start_translation_details) + assert poller.id is not None + # wait for result + if wait_for_operation: + result = poller.result() + for doc in result: + self._validate_doc_status(doc, "es") + # validate + self._validate_translation_metadata(poller=poller) + + return poller diff --git a/sdk/translation/azure-ai-translation-text/tests/preparer.py b/sdk/translation/azure-ai-translation-text/tests/preparer.py index 386845030733..24dd70e5fbb8 100644 --- a/sdk/translation/azure-ai-translation-text/tests/preparer.py +++ b/sdk/translation/azure-ai-translation-text/tests/preparer.py @@ -9,10 +9,10 @@ TextTranslationPreparer = functools.partial( EnvironmentVariableLoader, "translation", - translation_text_endpoint="https://fakeEndpoint.cognitive.microsofttranslator.com", - translation_text_custom_endpoint="https://fakeCustomEndpoint.cognitiveservices.azure.com", - translation_text_custom_apikey="fakeapikey", - translation_text_apikey="fakeapikey", - translation_text_region="fakeregion", - translation_text_resource_id="fakeResourceId", + text_translation_endpoint="https://fakeEndpoint.cognitive.microsofttranslator.com", + text_translation_custom_endpoint="https://fakeCustomEndpoint.cognitiveservices.azure.com", + text_translation_custom_apikey="fakeapikey", + text_translation_apikey="fakeapikey", + text_translation_region="fakeregion", + text_translation_resource_id="fakeResourceId", ) diff --git a/sdk/translation/azure-ai-translation-text/tests/test_break_sentence.py b/sdk/translation/azure-ai-translation-text/tests/test_break_sentence.py index 7cf35cc75a47..5ea0659a5f22 100644 --- a/sdk/translation/azure-ai-translation-text/tests/test_break_sentence.py +++ b/sdk/translation/azure-ai-translation-text/tests/test_break_sentence.py @@ -12,9 +12,9 @@ class TestBreakSentence(TextTranslationTest): @TextTranslationPreparer() @recorded_by_proxy def test_autodetect(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_client(endpoint, apikey, region) input_text_elements = ["Hello world"] @@ -27,9 +27,9 @@ def test_autodetect(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_with_language(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_client(endpoint, apikey, region) input_text_elements = [ @@ -45,9 +45,9 @@ def test_with_language(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_with_language_script(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_client(endpoint, apikey, region) input_text_elements = ["zhè shì gè cè shì。"] @@ -59,9 +59,9 @@ def test_with_language_script(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_with_multiple_languages(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_client(endpoint, apikey, region) input_text_elements = [ diff --git a/sdk/translation/azure-ai-translation-text/tests/test_break_sentence_async.py b/sdk/translation/azure-ai-translation-text/tests/test_break_sentence_async.py index f3cc51492225..cef2c50888d3 100644 --- a/sdk/translation/azure-ai-translation-text/tests/test_break_sentence_async.py +++ b/sdk/translation/azure-ai-translation-text/tests/test_break_sentence_async.py @@ -12,9 +12,9 @@ class TestBreakSentenceAsync(TextTranslationTest): @TextTranslationPreparer() @recorded_by_proxy_async async def test_autodetect(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_async_client(endpoint, apikey, region) input_text_elements = ["Hello world"] @@ -28,9 +28,9 @@ async def test_autodetect(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy_async async def test_with_language(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_async_client(endpoint, apikey, region) input_text_elements = [ @@ -47,9 +47,9 @@ async def test_with_language(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy_async async def test_with_language_script(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_async_client(endpoint, apikey, region) input_text_elements = ["zhè shì gè cè shì。"] @@ -64,9 +64,9 @@ async def test_with_language_script(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy_async async def test_with_multiple_languages(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_async_client(endpoint, apikey, region) input_text_elements = [ diff --git a/sdk/translation/azure-ai-translation-text/tests/test_dictionary_examples.py b/sdk/translation/azure-ai-translation-text/tests/test_dictionary_examples.py index d212e65fc154..b0af55dba4f6 100644 --- a/sdk/translation/azure-ai-translation-text/tests/test_dictionary_examples.py +++ b/sdk/translation/azure-ai-translation-text/tests/test_dictionary_examples.py @@ -13,9 +13,9 @@ class TestDictionaryExamples(TextTranslationTest): @TextTranslationPreparer() @recorded_by_proxy def test_single_input_element(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_client(endpoint, apikey, region) from_language = "en" @@ -32,9 +32,9 @@ def test_single_input_element(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_multiple_input_elements(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_client(endpoint, apikey, region) from_language = "en" diff --git a/sdk/translation/azure-ai-translation-text/tests/test_dictionary_examples_async.py b/sdk/translation/azure-ai-translation-text/tests/test_dictionary_examples_async.py index 1267ab0ca877..b0150f7a300b 100644 --- a/sdk/translation/azure-ai-translation-text/tests/test_dictionary_examples_async.py +++ b/sdk/translation/azure-ai-translation-text/tests/test_dictionary_examples_async.py @@ -13,9 +13,9 @@ class TestDictionaryExamplesAsync(TextTranslationTest): @TextTranslationPreparer() @recorded_by_proxy_async async def test_single_input_element(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_async_client(endpoint, apikey, region) from_language = "en" @@ -33,9 +33,9 @@ async def test_single_input_element(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy_async async def test_multiple_input_elements(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_async_client(endpoint, apikey, region) from_language = "en" diff --git a/sdk/translation/azure-ai-translation-text/tests/test_dictionary_lookup.py b/sdk/translation/azure-ai-translation-text/tests/test_dictionary_lookup.py index 6ba99b1eeee2..4f41246b69b9 100644 --- a/sdk/translation/azure-ai-translation-text/tests/test_dictionary_lookup.py +++ b/sdk/translation/azure-ai-translation-text/tests/test_dictionary_lookup.py @@ -12,9 +12,9 @@ class TestDictionaryLookup(TextTranslationTest): @TextTranslationPreparer() @recorded_by_proxy def test_single_input_element(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_client(endpoint, apikey, region) from_language = "en" @@ -31,9 +31,9 @@ def test_single_input_element(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_multiple_input_elements(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_client(endpoint, apikey, region) from_language = "en" diff --git a/sdk/translation/azure-ai-translation-text/tests/test_dictionary_lookup_async.py b/sdk/translation/azure-ai-translation-text/tests/test_dictionary_lookup_async.py index 7b976d537854..c4e35c82c2df 100644 --- a/sdk/translation/azure-ai-translation-text/tests/test_dictionary_lookup_async.py +++ b/sdk/translation/azure-ai-translation-text/tests/test_dictionary_lookup_async.py @@ -12,9 +12,9 @@ class TestDictionaryLookupAsync(TextTranslationTest): @TextTranslationPreparer() @recorded_by_proxy_async async def test_single_input_element(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_async_client(endpoint, apikey, region) from_language = "en" @@ -32,9 +32,9 @@ async def test_single_input_element(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy_async async def test_multiple_input_elements(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_async_client(endpoint, apikey, region) from_language = "en" diff --git a/sdk/translation/azure-ai-translation-text/tests/test_get_languages.py b/sdk/translation/azure-ai-translation-text/tests/test_get_languages.py index 220545901056..544a85c33006 100644 --- a/sdk/translation/azure-ai-translation-text/tests/test_get_languages.py +++ b/sdk/translation/azure-ai-translation-text/tests/test_get_languages.py @@ -12,7 +12,7 @@ class TestGetLanguages(TextTranslationTest): @TextTranslationPreparer() @recorded_by_proxy def test_all_scopes(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") + endpoint = kwargs.get("text_translation_endpoint") client = self.create_getlanguage_client(endpoint) response = client.get_supported_languages() @@ -23,7 +23,7 @@ def test_all_scopes(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_translation_scope(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") + endpoint = kwargs.get("text_translation_endpoint") client = self.create_getlanguage_client(endpoint) response = client.get_supported_languages(scope="translation") @@ -36,7 +36,7 @@ def test_translation_scope(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_transliteration_scope(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") + endpoint = kwargs.get("text_translation_endpoint") client = self.create_getlanguage_client(endpoint) response = client.get_supported_languages(scope="transliteration") @@ -62,7 +62,7 @@ def test_transliteration_scope(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_transliteration_multiple_scripts(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") + endpoint = kwargs.get("text_translation_endpoint") client = self.create_getlanguage_client(endpoint) response = client.get_supported_languages(scope="transliteration") @@ -79,7 +79,7 @@ def test_transliteration_multiple_scripts(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_dictionary_scope(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") + endpoint = kwargs.get("text_translation_endpoint") client = self.create_getlanguage_client(endpoint) response = client.get_supported_languages(scope="dictionary") @@ -97,7 +97,7 @@ def test_dictionary_scope(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_dictionary_multiple_translations(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") + endpoint = kwargs.get("text_translation_endpoint") client = self.create_getlanguage_client(endpoint) response = client.get_supported_languages(scope="dictionary") @@ -115,7 +115,7 @@ def test_dictionary_multiple_translations(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_with_culture(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") + endpoint = kwargs.get("text_translation_endpoint") client = self.create_getlanguage_client(endpoint) response = client.get_supported_languages(accept_language="es") diff --git a/sdk/translation/azure-ai-translation-text/tests/test_get_languages_async.py b/sdk/translation/azure-ai-translation-text/tests/test_get_languages_async.py index 20b4570ff772..e7818325453d 100644 --- a/sdk/translation/azure-ai-translation-text/tests/test_get_languages_async.py +++ b/sdk/translation/azure-ai-translation-text/tests/test_get_languages_async.py @@ -12,7 +12,7 @@ class TestGetLanguagesAsync(TextTranslationTest): @TextTranslationPreparer() @recorded_by_proxy_async async def test_all_scopes(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") + endpoint = kwargs.get("text_translation_endpoint") client = self.create_async_getlanguage_client(endpoint) async with client: response = await client.get_supported_languages() @@ -24,7 +24,7 @@ async def test_all_scopes(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy_async async def test_translation_scope(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") + endpoint = kwargs.get("text_translation_endpoint") client = self.create_async_getlanguage_client(endpoint) async with client: response = await client.get_supported_languages(scope="translation") @@ -38,7 +38,7 @@ async def test_translation_scope(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy_async async def test_transliteration_scope(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") + endpoint = kwargs.get("text_translation_endpoint") client = self.create_async_getlanguage_client(endpoint) async with client: response = await client.get_supported_languages(scope="transliteration") @@ -65,7 +65,7 @@ async def test_transliteration_scope(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy_async async def test_transliteration_multiple_scripts(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") + endpoint = kwargs.get("text_translation_endpoint") client = self.create_async_getlanguage_client(endpoint) async with client: response = await client.get_supported_languages(scope="transliteration") @@ -83,7 +83,7 @@ async def test_transliteration_multiple_scripts(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy_async async def test_dictionary_scope(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") + endpoint = kwargs.get("text_translation_endpoint") client = self.create_async_getlanguage_client(endpoint) async with client: response = await client.get_supported_languages(scope="dictionary") @@ -102,7 +102,7 @@ async def test_dictionary_scope(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy_async async def test_dictionary_multiple_translations(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") + endpoint = kwargs.get("text_translation_endpoint") client = self.create_async_getlanguage_client(endpoint) async with client: response = await client.get_supported_languages(scope="dictionary") @@ -121,7 +121,7 @@ async def test_dictionary_multiple_translations(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy_async async def test_with_culture(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") + endpoint = kwargs.get("text_translation_endpoint") client = self.create_async_getlanguage_client(endpoint) async with client: response = await client.get_supported_languages(accept_language="es") diff --git a/sdk/translation/azure-ai-translation-text/tests/test_translation.py b/sdk/translation/azure-ai-translation-text/tests/test_translation.py index 88462f347ebd..ba4098075df8 100644 --- a/sdk/translation/azure-ai-translation-text/tests/test_translation.py +++ b/sdk/translation/azure-ai-translation-text/tests/test_translation.py @@ -14,9 +14,9 @@ class TestTranslation(TextTranslationTest): @TextTranslationPreparer() @recorded_by_proxy def test_translate(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_client(endpoint, apikey, region) from_language = "es" @@ -32,9 +32,9 @@ def test_translate(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_autodetect(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_client(endpoint, apikey, region) to_language = ["cs"] @@ -51,9 +51,9 @@ def test_autodetect(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_no_translate_tag(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_client(endpoint, apikey, region) from_language = "zh-chs" @@ -73,9 +73,9 @@ def test_no_translate_tag(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_dictionary_tag(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_client(endpoint, apikey, region) from_language = "en" @@ -93,9 +93,9 @@ def test_dictionary_tag(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_transliteration(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_client(endpoint, apikey, region) from_language = "ar" @@ -118,9 +118,9 @@ def test_transliteration(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_from_to_latin(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_client(endpoint, apikey, region) from_language = "hi" @@ -142,9 +142,9 @@ def test_from_to_latin(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_multiple_input(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_client(endpoint, apikey, region) to_language = ["cs"] @@ -170,9 +170,9 @@ def test_multiple_input(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_multiple_target_languages(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_client(endpoint, apikey, region) to_language = ["cs", "es", "de"] @@ -190,9 +190,9 @@ def test_multiple_target_languages(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_different_texttypes(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_client(endpoint, apikey, region) to_language = ["cs"] @@ -207,9 +207,9 @@ def test_different_texttypes(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_profanity(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_client(endpoint, apikey, region) to_language = ["zh-cn"] @@ -230,9 +230,9 @@ def test_profanity(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_alignment(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_client(endpoint, apikey, region) to_language = ["cs"] @@ -248,9 +248,9 @@ def test_alignment(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_sentence_length(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_client(endpoint, apikey, region) to_language = ["fr"] @@ -269,9 +269,9 @@ def test_sentence_length(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_custom_endpoint(self, **kwargs): - endpoint = kwargs.get("translation_text_custom_endpoint") - apikey = kwargs.get("translation_text_custom_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_custom_endpoint") + apikey = kwargs.get("text_translation_custom_apikey") + region = kwargs.get("text_translation_region") client = self.create_client(endpoint, apikey, region) to_language = ["fr"] @@ -287,9 +287,9 @@ def test_custom_endpoint(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_token(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_client_token(endpoint, apikey, region, "https://api.microsofttranslator.com/") to_language = ["cs"] @@ -306,7 +306,7 @@ def test_token(self, **kwargs): @recorded_by_proxy def test_translate_aad(self, **kwargs): aadRegion = "westus2" - aadResourceId = kwargs.get("translation_text_resource_id") + aadResourceId = kwargs.get("text_translation_resource_id") token_credential = self.get_mt_credential(False) client = self.create_text_translation_client_with_aad(token_credential, aadRegion, aadResourceId) @@ -324,7 +324,7 @@ def test_translate_aad(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_translate_aad_custom(self, **kwargs): - endpoint = kwargs.get("translation_text_custom_endpoint") + endpoint = kwargs.get("text_translation_custom_endpoint") token_credential = self.get_mt_credential(False) client = self.create_text_translation_client_custom_with_aad(token_credential, endpoint=endpoint) diff --git a/sdk/translation/azure-ai-translation-text/tests/test_translation_async.py b/sdk/translation/azure-ai-translation-text/tests/test_translation_async.py index 1fe4b4a1079c..d2bff209f6d2 100644 --- a/sdk/translation/azure-ai-translation-text/tests/test_translation_async.py +++ b/sdk/translation/azure-ai-translation-text/tests/test_translation_async.py @@ -15,9 +15,9 @@ class TestTranslationAsync(TextTranslationTest): @TextTranslationPreparer() @recorded_by_proxy_async async def test_translate(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_async_client(endpoint, apikey, region) from_language = "es" @@ -36,9 +36,9 @@ async def test_translate(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy_async async def test_autodetect(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_async_client(endpoint, apikey, region) to_language = ["cs"] @@ -56,9 +56,9 @@ async def test_autodetect(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy_async async def test_no_translate_tag(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_async_client(endpoint, apikey, region) from_language = "zh-chs" @@ -79,9 +79,9 @@ async def test_no_translate_tag(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy_async async def test_dictionary_tag(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_async_client(endpoint, apikey, region) from_language = "en" @@ -102,9 +102,9 @@ async def test_dictionary_tag(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy_async async def test_transliteration(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_async_client(endpoint, apikey, region) from_language = "ar" @@ -128,9 +128,9 @@ async def test_transliteration(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy_async async def test_from_to_latin(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_async_client(endpoint, apikey, region) from_language = "hi" @@ -153,9 +153,9 @@ async def test_from_to_latin(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy_async async def test_multiple_input(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_async_client(endpoint, apikey, region) to_language = ["cs"] @@ -182,9 +182,9 @@ async def test_multiple_input(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy_async async def test_multiple_target_languages(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_async_client(endpoint, apikey, region) to_language = ["cs", "es", "de"] @@ -203,9 +203,9 @@ async def test_multiple_target_languages(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy_async async def test_different_texttypes(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_async_client(endpoint, apikey, region) to_language = ["cs"] @@ -223,9 +223,9 @@ async def test_different_texttypes(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy_async async def test_profanity(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_async_client(endpoint, apikey, region) to_language = ["zh-cn"] @@ -247,9 +247,9 @@ async def test_profanity(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy_async async def test_alignment(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_async_client(endpoint, apikey, region) to_language = ["cs"] @@ -266,9 +266,9 @@ async def test_alignment(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy_async async def test_sentence_length(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_async_client(endpoint, apikey, region) to_language = ["fr"] @@ -290,9 +290,9 @@ async def test_sentence_length(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy_async async def test_custom_endpoint(self, **kwargs): - endpoint = kwargs.get("translation_text_custom_endpoint") - apikey = kwargs.get("translation_text_custom_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_custom_endpoint") + apikey = kwargs.get("text_translation_custom_apikey") + region = kwargs.get("text_translation_region") client = self.create_async_client(endpoint, apikey, region) to_language = ["fr"] @@ -309,9 +309,9 @@ async def test_custom_endpoint(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy_async async def test_token(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_async_client_token(endpoint, apikey, region, "https://api.microsofttranslator.com/") to_language = ["cs"] @@ -329,7 +329,7 @@ async def test_token(self, **kwargs): @recorded_by_proxy_async async def test_translate_aad(self, **kwargs): aadRegion = "westus2" - aadResourceId = kwargs.get("translation_text_resource_id") + aadResourceId = kwargs.get("text_translation_resource_id") token_credential = self.get_mt_credential(True) client = self.create_async_text_translation_client_with_aad(token_credential, aadRegion, aadResourceId) diff --git a/sdk/translation/azure-ai-translation-text/tests/test_transliteration.py b/sdk/translation/azure-ai-translation-text/tests/test_transliteration.py index 353a690c15e5..dca33ad14409 100644 --- a/sdk/translation/azure-ai-translation-text/tests/test_transliteration.py +++ b/sdk/translation/azure-ai-translation-text/tests/test_transliteration.py @@ -13,9 +13,9 @@ class TestTransliteration(TextTranslationTest, TestHelper): @TextTranslationPreparer() @recorded_by_proxy def test_transliteration(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_client(endpoint, apikey, region) input_text_elements = ["这里怎么一回事?"] @@ -32,9 +32,9 @@ def test_transliteration(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_multiple_inputs(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_client(endpoint, apikey, region) input_text_elements = ["यहएककसौटीहैयहएककसौटीहै", "यहएककसौटीहै"] @@ -52,9 +52,9 @@ def test_multiple_inputs(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy def test_edit_distance(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_client(endpoint, apikey, region) input_text_elements = [ diff --git a/sdk/translation/azure-ai-translation-text/tests/test_transliteration_async.py b/sdk/translation/azure-ai-translation-text/tests/test_transliteration_async.py index 43785addd834..b8fa9e72837c 100644 --- a/sdk/translation/azure-ai-translation-text/tests/test_transliteration_async.py +++ b/sdk/translation/azure-ai-translation-text/tests/test_transliteration_async.py @@ -13,9 +13,9 @@ class TestTransliterationAsync(TextTranslationTest, TestHelper): @TextTranslationPreparer() @recorded_by_proxy_async async def test_transliteration(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_async_client(endpoint, apikey, region) input_text_elements = ["这里怎么一回事?"] @@ -33,9 +33,9 @@ async def test_transliteration(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy_async async def test_multiple_inputs(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_async_client(endpoint, apikey, region) input_text_elements = ["यहएककसौटीहैयहएककसौटीहै", "यहएककसौटीहै"] @@ -54,9 +54,9 @@ async def test_multiple_inputs(self, **kwargs): @TextTranslationPreparer() @recorded_by_proxy_async async def test_edit_distance(self, **kwargs): - endpoint = kwargs.get("translation_text_endpoint") - apikey = kwargs.get("translation_text_apikey") - region = kwargs.get("translation_text_region") + endpoint = kwargs.get("text_translation_endpoint") + apikey = kwargs.get("text_translation_apikey") + region = kwargs.get("text_translation_region") client = self.create_async_client(endpoint, apikey, region) input_text_elements = [ diff --git a/sdk/translation/test-resources-post.ps1 b/sdk/translation/test-resources-post.ps1 deleted file mode 100644 index 168598d1e769..000000000000 --- a/sdk/translation/test-resources-post.ps1 +++ /dev/null @@ -1,6 +0,0 @@ -if ($DeploymentOutputs["TRANSLATION_DOCUMENT_STORAGE_NAME"] -ne "pythontranslationstorage") { - $StorageAccount = Get-AzStorageAccount -ResourceGroupName $ResourceGroupName -Name $DeploymentOutputs["TRANSLATION_DOCUMENT_STORAGE_NAME"] - $ctx = $StorageAccount.Context - Set-AzStorageBlobContent -File "./sdk/translation/azure-ai-translation-document/samples/assets/glossary_sample.tsv" -Container "sourcecontainer" -Blob "glosario.tsv" -Context $ctx - Set-AzStorageBlobContent -File "./sdk/translation/azure-ai-translation-document/samples/assets/translate.txt" -Container "sourcecontainer" -Blob "translate.txt" -Context $ctx -} diff --git a/sdk/translation/test-resources.json b/sdk/translation/test-resources.json index db1f9f8382ee..05e9f16a84c8 100644 --- a/sdk/translation/test-resources.json +++ b/sdk/translation/test-resources.json @@ -1,5 +1,5 @@ { - "$schema": "https://schema.management.azure.com/schemas/2019-08-01/deploymentTemplate.json#", + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "baseName": { @@ -9,140 +9,52 @@ "description": "The base resource name." } }, - "location": { + "tenantId": { "type": "string", - "defaultValue": "[resourceGroup().location]", "metadata": { - "metadata": { - "description": "The location of the resource. By default, this is the same as the resource group." - } + "description": "The tenant ID to which the application and resources belong." } }, - "testApplicationOid": { + "testApplicationId": { "type": "string", "metadata": { - "description": "The principal to assign the role to. This is application object id." + "description": "The application client ID used to run tests." } }, - "tenantId": { + "testApplicationOid": { "type": "string", "metadata": { - "description": "The tenant id to which the application and resources belong." + "description": "The client OID to grant access to test resources." } }, - "testApplicationId": { + "location": { "type": "string", + "defaultValue": "[resourceGroup().location]", "metadata": { - "description": "The application client id used to run tests." + "description": "The location of the resource. By default, this is the same as the resource group." } }, - "cognitiveServicesEndpointSuffix": { - "defaultValue": ".cognitiveservices.azure.com/", + "endpointPrefix": { + "defaultValue": "doctranslation", "type": "string" }, - "useStaticStorageResource": { - "type": "bool", - "defaultValue": false, - "metadata": { - "description": "A static storage resource is used for Dogfood env." - } - }, - "staticStorageName": { - "defaultValue": "pythontranslationstorage", + "endpointSuffix": { + "defaultValue": ".cognitiveservices.azure.com", "type": "string" - }, - "blobStorageAccount": { - "type": "string", - "defaultValue": "[if(parameters('useStaticStorageResource'), parameters('staticStorageName'), parameters('baseName'))]" - }, - "storageAccResourceId": { - "type": "string", - "defaultValue": "[resourceId('Microsoft.Storage/storageAccounts', parameters('blobStorageAccount'))]" - }, - "targetContainerName_1": { - "type": "string", - "defaultValue": "testingcontainer1" - }, - "targetContainerSasProperties_1": { - "type": "object", - "defaultValue": { - "canonicalizedResource": "[concat('/blob/', parameters('blobStorageAccount'), '/', parameters('targetContainerName_1'))]", - "signedExpiry": "[dateTimeAdd(utcNow('u'), 'PT3H')]", - "signedPermission": "wl", - "signedResource": "c" - } - }, - "targetContainerName_2": { - "type": "string", - "defaultValue": "testingcontainer2" - }, - "targetContainerSasProperties_2": { - "type": "object", - "defaultValue": { - "canonicalizedResource": "[concat('/blob/', parameters('blobStorageAccount'), '/', parameters('targetContainerName_2'))]", - "signedExpiry": "[dateTimeAdd(utcNow('u'), 'PT3H')]", - "signedPermission": "wl", - "signedResource": "c" - } - }, - "targetContainerName_3": { - "type": "string", - "defaultValue": "testingcontainer3" - }, - "targetContainerSasProperties_3": { - "type": "object", - "defaultValue": { - "canonicalizedResource": "[concat('/blob/', parameters('blobStorageAccount'), '/', parameters('targetContainerName_3'))]", - "signedExpiry": "[dateTimeAdd(utcNow('u'), 'PT3H')]", - "signedPermission": "wl", - "signedResource": "c" - } - }, - "targetContainerName_4": { - "type": "string", - "defaultValue": "testingcontainer4" - }, - "targetContainerSasProperties_4": { - "type": "object", - "defaultValue": { - "canonicalizedResource": "[concat('/blob/', parameters('blobStorageAccount'), '/', parameters('targetContainerName_4'))]", - "signedExpiry": "[dateTimeAdd(utcNow('u'), 'PT3H')]", - "signedPermission": "wl", - "signedResource": "c" - } - }, - "sourceContainerName": { - "type": "string", - "defaultValue": "sourcecontainer" - }, - "sourceContainerSasProperties": { - "type": "object", - "defaultValue": { - "canonicalizedResource": "[concat('/blob/', parameters('blobStorageAccount'), '/', parameters('sourceContainerName'))]", - "signedExpiry": "[dateTimeAdd(utcNow('u'), 'PT3H')]", - "signedPermission": "rl", - "signedResource": "c" - } - }, - "glossaryFileName": { - "type": "string", - "defaultValue": "glosario.tsv" } }, "variables": { - "txtUniqueSubDomainName": "[concat('text', parameters('baseName'))]", + "txtUniqueSubDomainName": "[format('{0}', parameters('baseName'))]", "txtEndpointValue": "[format('https://api.cognitive.microsofttranslator.com')]", "txtCustomEndpointValue": "[format('https://{0}.cognitiveservices.azure.com', parameters('baseName'))]", "txtRegionValue": "[format('{0}', parameters('location'))]", + "roleDefinitionId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/a97b65f3-24c7-4388-baec-2e87135dc908')]", + "uniqueSubDomainName": "[format('{0}-{1}', parameters('baseName'), parameters('endpointPrefix'))]", + "endpointValue": "[format('https://{0}-{1}{2}', parameters('baseName'), parameters('endpointPrefix'), parameters('endpointSuffix'))]", "authorizationApiVersion": "2018-09-01-preview", - "docTranslationBaseName": "[parameters('baseName')]", - "docTranslationApiVersion": "2017-04-18", - "storageMgmtApiVersion": "2017-10-01", - "storageAccountName": "[parameters('blobStorageAccount')]", - "location": "[resourceGroup().location]", - "azureDocTranslationUrl": "[if(parameters('useStaticStorageResource'), concat('https://', variables('docTranslationBaseName'), '.ppe', parameters('cognitiveServicesEndpointSuffix')), concat('https://', variables('docTranslationBaseName'), parameters('cognitiveServicesEndpointSuffix')))]", - "azureStorageEndpoint": "[concat('https://', parameters('blobStorageAccount'), '.blob.core.windows.net/')]", - "cognitiveServiceUserRoleId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/a97b65f3-24c7-4388-baec-2e87135dc908')]", + "blobDataContributorRoleId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/ba92f5b4-2d11-453d-a403-e96b0029c9fe')]", + "storageAccountName": "[concat(parameters('baseName'), 'prim')]", + "storageAccountResourceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Storage/storageAccounts/',variables('storageAccountName'))]", "encryption": { "services": { "blob": { @@ -162,47 +74,33 @@ { "type": "Microsoft.CognitiveServices/accounts", "apiVersion": "2017-04-18", - "name": "[variables('txtUniqueSubDomainName')]", + "name": "[variables('uniqueSubDomainName')]", "location": "[parameters('location')]", "sku": { - "name": "S1" + "name": "S1" }, "kind": "TextTranslation", + "identity": { + "type": "SystemAssigned" + }, "properties": { - "customSubDomainName": "[variables('txtUniqueSubDomainName')]" - } - }, - { - "type": "Microsoft.Authorization/roleAssignments", - "apiVersion": "[variables('authorizationApiVersion')]", - "name": "[guid(concat(variables('cognitiveServiceUserRoleId'), variables('docTranslationBaseName')))]", - "dependsOn": [ - "[variables('docTranslationBaseName')]" - ], - "properties": { - "principalId": "[parameters('testApplicationOid')]", - "roleDefinitionId": "[variables('cognitiveServiceUserRoleId')]" + "customSubDomainName": "[variables('uniqueSubDomainName')]" } }, { - "type": "Microsoft.CognitiveServices/accounts", - "name": "[variables('docTranslationBaseName')]", - "apiVersion": "[variables('docTranslationApiVersion')]", - "sku": { - "name": "S1" - }, - "kind": "TextTranslation", - "location": "[parameters('location')]", + "type": "Microsoft.Authorization/roleAssignments", + "apiVersion": "2018-09-01-preview", + "name": "[guid(resourceGroup().id)]", "properties": { - "customSubDomainName": "[variables('docTranslationBaseName')]" + "roleDefinitionId": "[variables('roleDefinitionId')]", + "principalId": "[parameters('testApplicationOid')]" } }, { - "condition": "[not(parameters('useStaticStorageResource'))]", "type": "Microsoft.Storage/storageAccounts", - "apiVersion": "[variables('storageMgmtApiVersion')]", + "apiVersion": "2019-04-01", "name": "[variables('storageAccountName')]", - "location": "[variables('location')]", + "location": "[parameters('location')]", "sku": { "name": "Standard_RAGRS", "tier": "Standard" @@ -211,160 +109,80 @@ "properties": { "networkAcls": "[variables('networkAcls')]", "supportsHttpsTrafficOnly": true, + "allowSharedKeyAccess": true, "encryption": "[variables('encryption')]", - "accessTier": "Cool" + "accessTier": "Hot" + } + }, + { + "type": "Microsoft.Authorization/roleAssignments", + "apiVersion": "[variables('authorizationApiVersion')]", + "name": "[guid(concat('dataContributorRoleId', resourceGroup().id))]", + "scope": "[variables('storageAccountResourceId')]", + "properties": { + "roleDefinitionId": "[variables('blobDataContributorRoleId')]", + "principalId": "[reference(resourceId('Microsoft.CognitiveServices/accounts', variables('uniqueSubDomainName')), '2017-04-18', 'full').identity.principalId]", + "principalType": "ServicePrincipal" }, - "resources": [ - { - "condition": "[not(parameters('useStaticStorageResource'))]", - "type": "blobServices/containers", - "apiVersion": "[variables('storageMgmtApiVersion')]", - "name": "[concat('default/', parameters('targetContainerName_1'))]", - "dependsOn": [ - "[parameters('blobStorageAccount')]" - ] - }, - { - "condition": "[not(parameters('useStaticStorageResource'))]", - "type": "blobServices/containers", - "apiVersion": "[variables('storageMgmtApiVersion')]", - "name": "[concat('default/', parameters('targetContainerName_2'))]", - "dependsOn": [ - "[parameters('blobStorageAccount')]" - ] - }, - { - "condition": "[not(parameters('useStaticStorageResource'))]", - "type": "blobServices/containers", - "apiVersion": "[variables('storageMgmtApiVersion')]", - "name": "[concat('default/', parameters('targetContainerName_3'))]", - "dependsOn": [ - "[parameters('blobStorageAccount')]" - ] - }, - { - "condition": "[not(parameters('useStaticStorageResource'))]", - "type": "blobServices/containers", - "apiVersion": "[variables('storageMgmtApiVersion')]", - "name": "[concat('default/', parameters('targetContainerName_4'))]", - "dependsOn": [ - "[parameters('blobStorageAccount')]" - ] - }, - { - "condition": "[not(parameters('useStaticStorageResource'))]", - "type": "blobServices/containers", - "apiVersion": "[variables('storageMgmtApiVersion')]", - "name": "[concat('default/', parameters('sourceContainerName'))]", - "dependsOn": [ - "[parameters('blobStorageAccount')]" - ] - } + "dependsOn": [ + "[resourceId('Microsoft.CognitiveServices/accounts', variables('uniqueSubDomainName'))]", + "[variables('storageAccountResourceId')]" ] + }, + { + "type": "Microsoft.CognitiveServices/accounts", + "apiVersion": "2017-04-18", + "name": "[variables('txtUniqueSubDomainName')]", + "location": "[parameters('location')]", + "sku": { + "name": "S1" + }, + "kind": "TextTranslation", + "properties": { + "customSubDomainName": "[variables('txtUniqueSubDomainName')]" + } } ], - "outputs": { - "TRANSLATION_DOCUMENT_NAME": { - "type": "string", - "value": "[variables('docTranslationBaseName')]" - }, - "TRANSLATION_DOCUMENT_TEST_ENDPOINT": { + "outputs": { + "TEXT_TRANSLATION_ENDPOINT": { "type": "string", - "value": "[variables('azureDocTranslationUrl')]" - }, - "TRANSLATION_DOCUMENT_STORAGE_NAME": { - "type": "string", - "value": "[parameters('blobStorageAccount')]" - }, - "TRANSLATION_DOCUMENT_STORAGE_KEY": { - "condition": "[not(parameters('useStaticStorageResource'))]", - "type": "string", - "value": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), variables('storageMgmtApiVersion')).keys[0].value]" - }, - "AZURE_DOCUMENT_TRANSLATION_KEY": { - "type": "string", - "value": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', variables('docTranslationBaseName')), variables('docTranslationApiVersion')).key1]" - }, - "AZURE_DOCUMENT_TRANSLATION_ENDPOINT": { - "type": "string", - "value": "[variables('azureDocTranslationUrl')]" - }, - "AZURE_STORAGE_ACCOUNT_NAME": { - "type": "string", - "value": "[parameters('blobStorageAccount')]" - }, - "AZURE_STORAGE_SOURCE_KEY": { - "condition": "[not(parameters('useStaticStorageResource'))]", - "type": "string", - "value": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), variables('storageMgmtApiVersion')).keys[0].value]" - }, - "AZURE_STORAGE_SOURCE_ENDPOINT": { - "type": "string", - "value": "[variables('azureStorageEndpoint')]" - }, - "AZURE_SOURCE_CONTAINER_URL": { - "condition": "[not(parameters('useStaticStorageResource'))]", - "type": "string", - "value": "[concat(reference(parameters('storageAccResourceId'), '2019-06-01').primaryEndpoints.blob, parameters('sourceContainerName'), '?', listServiceSas(parameters('storageAccResourceId'), '2019-06-01', parameters('sourceContainerSasProperties')).serviceSasToken)]" - }, - "AZURE_SOURCE_CONTAINER_URL_1": { - "condition": "[not(parameters('useStaticStorageResource'))]", - "type": "string", - "value": "[concat(reference(parameters('storageAccResourceId'), '2019-06-01').primaryEndpoints.blob, parameters('sourceContainerName'), '?', listServiceSas(parameters('storageAccResourceId'), '2019-06-01', parameters('sourceContainerSasProperties')).serviceSasToken)]" - }, - "AZURE_SOURCE_CONTAINER_URL_2": { - "condition": "[not(parameters('useStaticStorageResource'))]", - "type": "string", - "value": "[concat(reference(parameters('storageAccResourceId'), '2019-06-01').primaryEndpoints.blob, parameters('sourceContainerName'), '?', listServiceSas(parameters('storageAccResourceId'), '2019-06-01', parameters('sourceContainerSasProperties')).serviceSasToken)]" - }, - "AZURE_TRANSLATION_GLOSSARY_URL": { - "condition": "[not(parameters('useStaticStorageResource'))]", - "type": "string", - "value": "[concat(reference(parameters('storageAccResourceId'), '2019-06-01').primaryEndpoints.blob, parameters('sourceContainerName'), '/', parameters('glossaryFileName'), '?', listServiceSas(parameters('storageAccResourceId'), '2019-06-01', parameters('sourceContainerSasProperties')).serviceSasToken)]" - }, - "AZURE_TARGET_CONTAINER_URL": { - "condition": "[not(parameters('useStaticStorageResource'))]", - "type": "string", - "value": "[concat(reference(parameters('storageAccResourceId'), '2019-06-01').primaryEndpoints.blob, parameters('targetContainerName_1'), '?', listServiceSas(parameters('storageAccResourceId'), '2019-06-01', parameters('targetContainerSasProperties_1')).serviceSasToken)]" + "value": "[variables('txtEndpointValue')]" }, - "AZURE_TARGET_CONTAINER_URL_FR": { - "condition": "[not(parameters('useStaticStorageResource'))]", + "TEXT_TRANSLATION_APIKEY": { "type": "string", - "value": "[concat(reference(parameters('storageAccResourceId'), '2019-06-01').primaryEndpoints.blob, parameters('targetContainerName_2'), '?', listServiceSas(parameters('storageAccResourceId'), '2019-06-01', parameters('targetContainerSasProperties_2')).serviceSasToken)]" + "value": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', variables('txtUniqueSubDomainName')), '2017-04-18').key1]" }, - "AZURE_TARGET_CONTAINER_URL_AR": { - "condition": "[not(parameters('useStaticStorageResource'))]", + "TEXT_TRANSLATION_CUSTOM_ENDPOINT": { "type": "string", - "value": "[concat(reference(parameters('storageAccResourceId'), '2019-06-01').primaryEndpoints.blob, parameters('targetContainerName_3'), '?', listServiceSas(parameters('storageAccResourceId'), '2019-06-01', parameters('targetContainerSasProperties_3')).serviceSasToken)]" + "value": "[variables('txtCustomEndpointValue')]" }, - "AZURE_TARGET_CONTAINER_URL_ES": { - "condition": "[not(parameters('useStaticStorageResource'))]", + "TEXT_TRANSLATION_CUSTOM_APIKEY": { "type": "string", - "value": "[concat(reference(parameters('storageAccResourceId'), '2019-06-01').primaryEndpoints.blob, parameters('targetContainerName_4'), '?', listServiceSas(parameters('storageAccResourceId'), '2019-06-01', parameters('targetContainerSasProperties_4')).serviceSasToken)]" + "value": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', variables('txtUniqueSubDomainName')), '2017-04-18').key1]" }, - "TRANSLATION_TEXT_APIKEY": { + "TEXT_TRANSLATION_REGION": { "type": "string", - "value": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', variables('txtUniqueSubDomainName')), '2017-04-18').key1]" + "value": "[variables('txtRegionValue')]" }, - "TRANSLATION_TEXT_ENDPOINT": { + "TEXT_TRANSLATION_RESOURCE_ID": { "type": "string", - "value": "[variables('txtEndpointValue')]" + "value": "[resourceId('Microsoft.CognitiveServices/accounts', variables('txtUniqueSubDomainName'))]" }, - "TRANSLATION_TEXT_CUSTOM_ENDPOINT": { + "DOCUMENT_TRANSLATION_ENDPOINT": { "type": "string", - "value": "[variables('txtCustomEndpointValue')]" + "value": "[variables('endpointValue')]" }, - "TRANSLATION_TEXT_CUSTOM_APIKEY": { + "DOCUMENT_TRANSLATION_API_KEY": { "type": "string", - "value": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', variables('docTranslationBaseName')), variables('docTranslationApiVersion')).key1]" + "value": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', variables('uniqueSubDomainName')), '2017-04-18').key1]" }, - "TRANSLATION_TEXT_REGION": { + "DOCUMENT_TRANSLATION_STORAGE_NAME": { "type": "string", - "value": "[variables('txtRegionValue')]" + "value": "[variables('storageAccountName')]" }, - "TRANSLATION_TEXT_RESOURCE_ID": { + "DOCUMENT_TRANSLATION_STORAGE_KEY": { "type": "string", - "value": "[resourceId('Microsoft.CognitiveServices/accounts', variables('txtUniqueSubDomainName'))]" + "value": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2019-04-01').keys[0].value]" } } -} \ No newline at end of file +}