Skip to content

Commit f16b4fa

Browse files
authored
Merge pull request #223979 from laujan/59316-disconnected-container-documentation
59316 disconnected container documentation [Translator]
2 parents 379c269 + 921ad34 commit f16b4fa

File tree

3 files changed

+285
-1
lines changed

3 files changed

+285
-1
lines changed
Lines changed: 284 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,284 @@
1+
---
2+
title: Use Translator Docker containers in disconnected environments
3+
titleSuffix: Azure Cognitive Services
4+
description: Learn how to run Azure Cognitive Services Translator containers in disconnected environments.
5+
services: cognitive-services
6+
author: laujan
7+
manager: nitinme
8+
ms.service: cognitive-services
9+
ms.topic: reference
10+
ms.date: 01/13/2023
11+
ms.author: lajanuar
12+
---
13+
14+
<!-- markdownlint-disable MD036 -->
15+
<!-- markdownlint-disable MD001 -->
16+
17+
# Use Translator containers in disconnected environments
18+
19+
Azure Cognitive Services Translator containers allow you to use Translator Service APIs with the benefits of containerization. Disconnected containers are offered through commitment tier pricing offered at a discounted rate compared to pay-as-you-go pricing. With commitment tier pricing, you can commit to using Translator Service features for a fixed fee, at a predictable total cost, based on the needs of your workload.
20+
21+
## Get started
22+
23+
Before attempting to run a Docker container in an offline environment, make sure you're familiar with the following requirements to successfully download and use the container:
24+
25+
* Host computer requirements and recommendations.
26+
* The Docker `pull` command you'll use to download the container.
27+
* How to validate that a container is running.
28+
* How to send queries to the container's endpoint, once it's running.
29+
30+
## Request access to use containers in disconnected environments
31+
32+
Complete and submit the [request form](https://aka.ms/csdisconnectedcontainers) to request access to the containers disconnected from the Internet.
33+
34+
[!INCLUDE [Request access to public preview](../../../../includes/cognitive-services-containers-request-access.md)]
35+
36+
Access is limited to customers that meet the following requirements:
37+
38+
* Your organization should be identified as strategic customer or partner with Microsoft.
39+
* Disconnected containers are expected to run fully offline, hence your use cases must meet at least one of these or similar requirements:
40+
* Environment or device(s) with zero connectivity to internet.
41+
* Remote location that occasionally has internet access.
42+
* Organization under strict regulation of not sending any kind of data back to cloud.
43+
* Application completed as instructed. Make certain to pay close attention to guidance provided throughout the application to ensure you provide all the necessary information required for approval.
44+
45+
## Create a new resource and purchase a commitment plan
46+
47+
1. Create a [Translator resource](https://portal.azure.com/#create/Microsoft.CognitiveServicesTextTranslation) in the Azure portal.
48+
49+
1. Enter the applicable information to create your resource. Be sure to select **Commitment tier disconnected containers** as your pricing tier.
50+
51+
> [!NOTE]
52+
>
53+
> * You will only see the option to purchase a commitment tier if you have been approved by Microsoft.
54+
55+
:::image type="content" source="../media/create-resource-offline-container.png" alt-text="A screenshot showing resource creation on the Azure portal.":::
56+
57+
1. Select **Review + Create** at the bottom of the page. Review the information, and select **Create**.
58+
59+
## Gather required parameters
60+
61+
There are three required parameters for all Cognitive Services' containers:
62+
63+
* The end-user license agreement (EULA) must be present with a value of *accept*.
64+
* The endpoint URL for your resource from the Azure portal.
65+
* The API key for your resource from the Azure portal.
66+
67+
Both the endpoint URL and API key are needed when you first run the container to configure it for disconnected usage. You can find the key and endpoint on the **Key and endpoint** page for your resource in the Azure portal:
68+
69+
:::image type="content" source="../media/quickstarts/keys-and-endpoint-portal.png" alt-text="Screenshot of Azure portal keys and endpoint page.":::
70+
71+
> [!IMPORTANT]
72+
> You will only use your key and endpoint to configure the container to run in a disconnected environment. After you configure the container, you won't need the key and endpoint values to send API requests. Store them securely, for example, using Azure Key Vault. Only one key is necessary for this process.
73+
74+
## Download a Docker container with `docker pull`
75+
76+
Download the Docker container that has been approved to run in a disconnected environment. For example:
77+
78+
|Docker pull command | Value |Format|
79+
|----------|-------|------|
80+
|&bullet; **`docker pull [image]`**</br>&bullet; **`docker pull [image]:latest`**|The latest container image.|&bullet; mcr.microsoft.com/azure-cognitive-services/translator/text-translation</br> </br>&bullet; mcr.microsoft.com/azure-cognitive-services/translator/text-translation: latest |
81+
|||
82+
|&bullet; **`docker pull [image]:[version]`** | A specific container image |mcr.microsoft.com/azure-cognitive-services/translator/text-translation:1.0.019410001-amd64 |
83+
84+
**Example Docker pull command**
85+
86+
```docker
87+
docker pull mcr.microsoft.com/azure-cognitive-services/translator/text-translation:latest
88+
```
89+
90+
## Configure the container to run in a disconnected environment
91+
92+
Now that you've downloaded your container, you'll need to execute the `docker run` command with the following parameters:
93+
94+
* **`DownloadLicense=True`**. This parameter will download a license file that will enable your Docker container to run when it isn't connected to the internet. It also contains an expiration date, after which the license file will be invalid to run the container. You can only use the license file in corresponding approved container.
95+
* **`Languages={language list}`**. You must include this parameter to download model files for the [languages](../language-support.md) you want to translate.
96+
97+
> [!IMPORTANT]
98+
> The `docker run` command will generate a template that you can use to run the container. The template contains parameters you'll need for the downloaded models and configuration file. Make sure you save this template.
99+
100+
The following example shows the formatting for the `docker run` command with placeholder values. Replace these placeholder values with your own values.
101+
102+
| Placeholder | Value | Format|
103+
|-------------|-------|---|
104+
| `[image]` | The container image you want to use. | `mcr.microsoft.com/azure-cognitive-services/translator/text-translation` |
105+
| `{LICENSE_MOUNT}` | The path where the license will be downloaded, and mounted. | `/host/license:/path/to/license/directory` |
106+
| `{MODEL_MOUNT_PATH}`| The path where the machine translation models will be downloaded, and mounted. Your directory structure must be formatted as **/usr/local/models** | `/host/translator/models:/usr/local/models`|
107+
| `{ENDPOINT_URI}` | The endpoint for authenticating your service request. You can find it on your resource's **Key and endpoint** page, in the Azure portal. | `https://<your-custom-subdomain>.cognitiveservices.azure.com` |
108+
| `{API_KEY}` | The key for your Text Analytics resource. You can find it on your resource's **Key and endpoint** page, in the Azure portal. |`{string}`|
109+
| `{LANGUAGES_LIST}` | List of language codes separated by commas. It is mandatory to have English (en) language as part of the list.|en,fr,it,ta,uk |
110+
| `{CONTAINER_LICENSE_DIRECTORY}` | Location of the license folder on the container's local filesystem. | `/path/to/license/directory` |
111+
112+
**Example `docker run` command**
113+
114+
```docker
115+
116+
docker run --rm -it -p 5000:5000
117+
118+
-v {MODEL_MOUNT_PATH} \
119+
120+
-v {LICENSE_MOUNT_PATH} \
121+
122+
-e Mounts:License={CONTAINER_LICENSE_DIRECTORY} \
123+
124+
-e DownloadLicense=true \
125+
126+
-e eula=accept \
127+
128+
-e billing={ENDPOINT_URI} \
129+
130+
-e apikey={API_KEY} \
131+
132+
-e Languages={LANGUAGES_LIST} \
133+
134+
[image]
135+
```
136+
137+
### Translator translation models and container configuration
138+
139+
After you've [configured the container](#configure-the-container-to-run-in-a-disconnected-environment), the values for the downloaded translation models and container configuration will be generated and displayed in the container output:
140+
141+
```bash
142+
-e MODELS= usr/local/models/model1/, usr/local/models/model2/
143+
-e TRANSLATORSYSTEMCONFIG=/usr/local/models/Config/5a72fa7c-394b-45db-8c06-ecdfc98c0832
144+
```
145+
146+
## Run the container in a disconnected environment
147+
148+
Once the license file has been downloaded, you can run the container in a disconnected environment with your license, appropriate memory, and suitable CPU allocations. The following example shows the formatting of the `docker run` command with placeholder values. Replace these placeholders values with your own values.
149+
150+
Whenever the container is run, the license file must be mounted to the container and the location of the license folder on the container's local filesystem must be specified with `Mounts:License=`. In addition, an output mount must be specified so that billing usage records can be written.
151+
152+
Placeholder | Value | Format|
153+
|-------------|-------|---|
154+
| `[image]`| The container image you want to use. | `mcr.microsoft.com/azure-cognitive-services/translator/text-translation` |
155+
`{MEMORY_SIZE}` | The appropriate size of memory to allocate for your container. | `16g` |
156+
| `{NUMBER_CPUS}` | The appropriate number of CPUs to allocate for your container. | `4` |
157+
| `{LICENSE_MOUNT}` | The path where the license will be located and mounted. | `/host/translator/license:/path/to/license/directory` |
158+
|`{MODEL_MOUNT_PATH}`| The path where the machine translation models will be downloaded, and mounted. Your directory structure must be formatted as **/usr/local/models** | `/host/translator/models:/usr/local/models`|
159+
|`{MODELS_DIRECTORY_LIST}`|List of comma separated directories each having a machine translation model. | `/usr/local/models/enu_esn_generalnn_2022240501,/usr/local/models/esn_enu_generalnn_2022240501` |
160+
| `{OUTPUT_PATH}` | The output path for logging [usage records](#usage-records). | `/host/output:/path/to/output/directory` |
161+
| `{CONTAINER_LICENSE_DIRECTORY}` | Location of the license folder on the container's local filesystem. | `/path/to/license/directory` |
162+
| `{CONTAINER_OUTPUT_DIRECTORY}` | Location of the output folder on the container's local filesystem. | `/path/to/output/directory` |
163+
|`{TRANSLATOR_CONFIG_JSON}`| Translator system configuration file used by container internally.| `/usr/local/models/Config/5a72fa7c-394b-45db-8c06-ecdfc98c0832` |
164+
165+
**Example `docker run` command**
166+
167+
```docker
168+
169+
docker run --rm -it -p 5000:5000 --memory {MEMORY_SIZE} --cpus {NUMBER_CPUS} \
170+
171+
-v {MODEL_MOUNT_PATH} \
172+
173+
-v {LICENSE_MOUNT_PATH} \
174+
175+
-v {OUTPUT_MOUNT_PATH} \
176+
177+
-e Mounts:License={CONTAINER_LICENSE_DIRECTORY} \
178+
179+
-e Mounts:Output={CONTAINER_OUTPUT_DIRECTORY} \
180+
181+
-e MODELS={MODELS_DIRECTORY_LIST} \
182+
183+
-e TRANSLATORSYSTEMCONFIG={TRANSLATOR_CONFIG_JSON} \
184+
185+
-e eula=accept \
186+
187+
[image]
188+
```
189+
190+
## Other parameters and commands
191+
192+
Here are a few more parameters and commands you may need to run the container:
193+
194+
#### Usage records
195+
196+
When operating Docker containers in a disconnected environment, the container will write usage records to a volume where they're collected over time. You can also call a REST API endpoint to generate a report about service usage.
197+
198+
#### Arguments for storing logs
199+
200+
When run in a disconnected environment, an output mount must be available to the container to store usage logs. For example, you would include `-v /host/output:{OUTPUT_PATH}` and `Mounts:Output={OUTPUT_PATH}` in the following example, replacing `{OUTPUT_PATH}` with the path where the logs will be stored:
201+
202+
**Example `docker run` command**
203+
204+
```docker
205+
docker run -v /host/output:{OUTPUT_PATH} ... <image> ... Mounts:Output={OUTPUT_PATH}
206+
```
207+
208+
#### Get records using the container endpoints
209+
210+
The container provides two endpoints for returning records regarding its usage.
211+
212+
#### Get all records
213+
214+
The following endpoint will provide a report summarizing all of the usage collected in the mounted billing record directory.
215+
216+
```HTTP
217+
https://<service>/records/usage-logs/
218+
```
219+
220+
**Example HTTPS endpoint**
221+
222+
`http://localhost:5000/records/usage-logs`
223+
224+
The usage-logs endpoint will return a JSON response similar to the following example:
225+
226+
```json
227+
{
228+
"apiType": "string",
229+
"serviceName": "string",
230+
"meters": [
231+
{
232+
"name": "string",
233+
"quantity": 256345435
234+
}
235+
]
236+
}
237+
```
238+
239+
#### Get records for a specific month
240+
241+
The following endpoint will provide a report summarizing usage over a specific month and year:
242+
243+
```HTTP
244+
https://<service>/records/usage-logs/{MONTH}/{YEAR}
245+
```
246+
247+
This usage-logs endpoint will return a JSON response similar to the following example:
248+
249+
```json
250+
{
251+
"apiType": "string",
252+
"serviceName": "string",
253+
"meters": [
254+
{
255+
"name": "string",
256+
"quantity": 56097
257+
}
258+
]
259+
}
260+
```
261+
262+
### Purchase a different commitment plan for disconnected containers
263+
264+
Commitment plans for disconnected containers have a calendar year commitment period. When you purchase a plan, you'll be charged the full price immediately. During the commitment period, you can't change your commitment plan, however you can purchase more unit(s) at a pro-rated price for the remaining days in the year. You have until midnight (UTC) on the last day of your commitment, to end a commitment plan.
265+
266+
You can choose a different commitment plan in the **Commitment tier pricing** settings of your resource under the **Resource Management** section.
267+
268+
### End a commitment plan
269+
270+
If you decide that you don't want to continue purchasing a commitment plan, you can set your resource's auto-renewal to **Do not auto-renew**. Your commitment plan will expire on the displayed commitment end date. After this date, you won't be charged for the commitment plan. You'll be able to continue using the Azure resource to make API calls, charged at pay-as-you-go pricing. You'll have until midnight (UTC) on the last day of the year to end a commitment plan for disconnected containers. If you do so, you won't be charged for the following year.
271+
272+
## Troubleshooting
273+
274+
Run the container with an output mount and logging enabled. These settings will enable the container to generate log files that are helpful for troubleshooting issues that occur while starting or running the container.
275+
276+
> [!TIP]
277+
> For more troubleshooting information and guidance, see [Disconnected containers Frequently asked questions (FAQ)](../../containers/disconnected-container-faq.yml).
278+
279+
That's it! You've learned how to create and run disconnected containers for Azure Translator Service.
280+
281+
## Next steps
282+
283+
> [!div class="nextstepaction"]
284+
> [Request parameters for Translator text containers](translator-container-supported-parameters.md)
26.8 KB
Loading

articles/cognitive-services/Translator/toc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ items:
8787
href: containers/translator-container-configuration.md
8888
- name: Use containers in disconnected environments
8989
displayName: text,docker,pull,mcr,registry,commitment,parameters
90-
href: ../containers/disconnected-containers.md
90+
href: containers/translator-disconnected-containers.md
9191
- name: "Container: Translate"
9292
displayName: textType,text type,preview,POST,parameters,request,
9393
href: containers/translator-container-supported-parameters.md

0 commit comments

Comments
 (0)