|
| 1 | +--- |
| 2 | +title: Use For containers in disconnected environments |
| 3 | +titleSuffix: Azure Cognitive Services |
| 4 | +description: Learn how to run Azure Cognitive Services Docker containers disconnected from the internet. |
| 5 | +services: applied-ai-services |
| 6 | +ms.subservice: forms-recognizer |
| 7 | +author: laujan |
| 8 | +manager: nitinme |
| 9 | +ms.service: cognitive-services |
| 10 | +ms.topic: reference |
| 11 | +ms.date: 01/18/2023 |
| 12 | +ms.author: lajanuar |
| 13 | +--- |
| 14 | + |
| 15 | +# Use Form Recognizer containers in disconnected environments |
| 16 | + |
| 17 | +<!-- markdownlint-disable MD036 --> |
| 18 | +<!-- markdownlint-disable MD001 --> |
| 19 | + |
| 20 | +Azure Cognitive Services Form Recognizer containers allow you to use Form Recognizer 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 Form Recognizer features for a fixed fee, at a predictable total cost, based on the needs of your workload. |
| 21 | + |
| 22 | +## Get Started |
| 23 | + |
| 24 | +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: |
| 25 | + |
| 26 | +* Host computer requirements and recommendations. |
| 27 | +* The Docker `pull` command you'll use to download the container. |
| 28 | +* How to validate that a container is running. |
| 29 | +* How to send queries to the container's endpoint, once it's running. |
| 30 | + |
| 31 | +## Request access to use containers in disconnected environments |
| 32 | + |
| 33 | +Complete and submit the [request form](https://aka.ms/csdisconnectedcontainers) to request access to the containers disconnected from the Internet. |
| 34 | + |
| 35 | +[!INCLUDE [Request access to public preview](../../../../includes/cognitive-services-containers-request-access.md)] |
| 36 | + |
| 37 | +Access is limited to customers that meet the following requirements: |
| 38 | + |
| 39 | +* Your organization should be identified as strategic customer or partner with Microsoft. |
| 40 | +* Disconnected containers are expected to run fully offline, hence your use cases must meet one of below or similar requirements: |
| 41 | + * Environment or device(s) with zero connectivity to internet. |
| 42 | + * Remote location that occasionally has internet access. |
| 43 | + * Organization under strict regulation of not sending any kind of data back to cloud. |
| 44 | +* Application completed as instructed - Please pay close attention to guidance provided throughout the application to ensure you provide all the necessary information required for approval. |
| 45 | + |
| 46 | +## Create a new resource and purchase a commitment plan |
| 47 | + |
| 48 | +1. Create a new [Form Recognizer resource](https://portal.azure.com/#create/Microsoft.CognitiveServicesFormRecognizer) in the Azure portal. |
| 49 | + |
| 50 | +1. Enter the applicable information to create your resource. Be sure to select **Commitment tier disconnected containers** as your pricing tier. |
| 51 | + |
| 52 | + > [!NOTE] |
| 53 | + > |
| 54 | + > * You will only see the option to purchase a commitment tier if you have been approved by Microsoft. |
| 55 | +
|
| 56 | + :::image type="content" source="../media/create-resource-offline-container.png" alt-text="A screenshot showing resource creation on the Azure portal."::: |
| 57 | + |
| 58 | +1. Select **Review + Create** at the bottom of the page. Review the information, and select **Create**. |
| 59 | + |
| 60 | +## Gather required parameters |
| 61 | + |
| 62 | +There are three required parameters for all Cognitive Services' containers: |
| 63 | + |
| 64 | +* The end-user license agreement (EULA) must be present with a value of *accept*. |
| 65 | +* The endpoint URL for your resource from the Azure portal. |
| 66 | +* The API key for your resource from the Azure portal. |
| 67 | + |
| 68 | +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: |
| 69 | + |
| 70 | + :::image type="content" source="../media/containers/keys-and-endpoint.png" alt-text="Screenshot: Azure portal keys and endpoint page."::: |
| 71 | + |
| 72 | +> [!IMPORTANT] |
| 73 | +> 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. |
| 74 | +
|
| 75 | +## Download a Docker container with `docker pull` |
| 76 | + |
| 77 | +Download the Docker container that has been approved to run in a disconnected environment. For example: |
| 78 | + |
| 79 | +|Docker pull command | Value |Format| |
| 80 | +|----------|-------|------| |
| 81 | +|• **`docker pull [image]`**</br>• **`docker pull [image]:latest`**|The latest container image.|• mcr.microsoft.com/azure-cognitive-services/form-recognizer/layout</br> </br>• mcr.microsoft.com/azure-cognitive-services/form-recognizer/invoice: latest | |
| 82 | +||| |
| 83 | +|• **`docker pull [image]:[version]`** | A specific container image |docker pull mcr.microsoft.com/azure-cognitive-services/form-recognizer/receipt:2.1-preview | |
| 84 | + |
| 85 | + **Example Docker pull command** |
| 86 | + |
| 87 | +```docker |
| 88 | +docker pull mcr.microsoft.com/azure-cognitive-services/form-recognizer/invoice:latest |
| 89 | +``` |
| 90 | + |
| 91 | +## Configure the container to be run in a disconnected environment |
| 92 | + |
| 93 | +Now that you've downloaded your container, you'll need to execute the `docker run` command with the following parameter: |
| 94 | + |
| 95 | +* **`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. |
| 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 you'll use, with placeholder values. Replace these placeholder values with your own values. |
| 101 | + |
| 102 | +| Placeholder | Value | Format or example | |
| 103 | +|-------------|-------|---| |
| 104 | +| `{IMAGE}` | The container image you want to use. | `mcr.microsoft.com/azure-cognitive-services/form-recognizer/invoice` | |
| 105 | +| `{LICENSE_MOUNT}` | The path where the license will be downloaded, and mounted. | `/host/license:/path/to/license/directory` | |
| 106 | +| `{ENDPOINT_URI}` | The endpoint for authenticating your service request. You can find it on your resource's **Key and endpoint** page, on the Azure portal. | `https://<your-custom-subdomain>.cognitiveservices.azure.com` | |
| 107 | +| `{API_KEY}` | The key for your Text Analytics resource. You can find it on your resource's **Key and endpoint** page, on the Azure portal. |`{string}`| |
| 108 | +| `{CONTAINER_LICENSE_DIRECTORY}` | Location of the license folder on the container's local filesystem. | `/path/to/license/directory` | |
| 109 | + |
| 110 | + **Example `docker run` command** |
| 111 | + |
| 112 | +```docker |
| 113 | +
|
| 114 | +docker run --rm -it -p 5000:5000 \ |
| 115 | + |
| 116 | +-v {LICENSE_MOUNT} \ |
| 117 | +
|
| 118 | +{IMAGE} \ |
| 119 | +
|
| 120 | +eula=accept \ |
| 121 | +
|
| 122 | +billing={ENDPOINT_URI} \ |
| 123 | +
|
| 124 | +apikey={API_KEY} \ |
| 125 | +
|
| 126 | +DownloadLicense=True \ |
| 127 | +
|
| 128 | +Mounts:License={CONTAINER_LICENSE_DIRECTORY} |
| 129 | +``` |
| 130 | + |
| 131 | +After you've configured the container, use the next section to run the container in your environment with the license, and appropriate memory and CPU allocations. |
| 132 | + |
| 133 | +**TODO** |
| 134 | + |
| 135 | +## Form Recognizer models and container configuration |
| 136 | + |
| 137 | +> [!IMPORTANT] |
| 138 | +> If you're using the Translator, Neural text-to-speech, or Speech-to-text containers, read the **Additional parameters** section below for information on commands or additional parameters you will need to use. |
| 139 | +
|
| 140 | +Once the license file has been downloaded, you can run the container in a disconnected environment. The following example shows the formatting of the `docker run` command you'll use, with placeholder values. Replace these placeholder values with your own values. |
| 141 | + |
| 142 | +Wherever 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=`. An output mount must also be specified so that billing usage records can be written. |
| 143 | + |
| 144 | +Placeholder | Value | Format or example | |
| 145 | +|-------------|-------|---| |
| 146 | +| `{IMAGE}` | The container image you want to use. | `mcr.microsoft.com/azure-cognitive-services/form-recognizer/invoice` | |
| 147 | + `{MEMORY_SIZE}` | The appropriate size of memory to allocate for your container. | `4g` | |
| 148 | +| `{NUMBER_CPUS}` | The appropriate number of CPUs to allocate for your container. | `4` | |
| 149 | +| `{LICENSE_MOUNT}` | The path where the license will be located and mounted. | `/host/license:/path/to/license/directory` | |
| 150 | +| `{OUTPUT_PATH}` | The output path for logging [usage records](#usage-records). | `/host/output:/path/to/output/directory` | |
| 151 | +| `{CONTAINER_LICENSE_DIRECTORY}` | Location of the license folder on the container's local filesystem. | `/path/to/license/directory` | |
| 152 | +| `{CONTAINER_OUTPUT_DIRECTORY}` | Location of the output folder on the container's local filesystem. | `/path/to/output/directory` | |
| 153 | + |
| 154 | +```bash |
| 155 | +docker run --rm -it -p 5000:5000 --memory {MEMORY_SIZE} --cpus {NUMBER_CPUS} \ |
| 156 | +-v {LICENSE_MOUNT} \ |
| 157 | +-v {OUTPUT_PATH} \ |
| 158 | +{IMAGE} \ |
| 159 | +eula=accept \ |
| 160 | +Mounts:License={CONTAINER_LICENSE_DIRECTORY} |
| 161 | +Mounts:Output={CONTAINER_OUTPUT_DIRECTORY} |
| 162 | +``` |
| 163 | + |
| 164 | +### Additional parameters and commands |
| 165 | + |
| 166 | +See the following sections for additional parameters and commands you may need to run the container. |
| 167 | + |
| 168 | +#### Translator container |
| 169 | + |
| 170 | +If you're using the [Translator container](../translator/containers/translator-how-to-install-container.md), you'll need to add parameters for the downloaded translation models and container configuration. These values are generated and displayed in the container output when you [configure the container](#configure-the-container-to-be-run-in-a-disconnected-environment) as described above. For example: |
| 171 | + |
| 172 | +```bash |
| 173 | +-e MODELS= /path/to/model1/, /path/to/model2/ |
| 174 | +-e TRANSLATORSYSTEMCONFIG=/path/to/model/config/translatorsystemconfig.json |
| 175 | +``` |
| 176 | + |
| 177 | +#### Speech-to-text and Neural text-to-speech containers |
| 178 | + |
| 179 | +The [speech-to-text](../speech-service/speech-container-howto.md?tabs=stt) and [neural text-to-speech](../speech-service/speech-container-howto.md?tabs=ntts) containers provide a default directory for writing the license file and billing log at runtime. The default directories are /license and /output respectively. |
| 180 | + |
| 181 | +When you're mounting these directories to the container with the `docker run -v` command, make sure the local machine directory is set ownership to `user:group nonroot:nonroot` before running the container. |
| 182 | + |
| 183 | +Below is a sample command to set file/directory ownership. |
| 184 | + |
| 185 | +```bash |
| 186 | +sudo chown -R nonroot:nonroot <YOUR_LOCAL_MACHINE_PATH_1> <YOUR_LOCAL_MACHINE_PATH_2> ... |
| 187 | +``` |
| 188 | + |
| 189 | +## Usage records |
| 190 | + |
| 191 | +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 endpoint to generate a report about service usage. |
| 192 | + |
| 193 | +### Arguments for storing logs |
| 194 | + |
| 195 | +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 example below, replacing `{OUTPUT_PATH}` with the path where the logs will be stored: |
| 196 | + |
| 197 | +```Docker |
| 198 | +docker run -v /host/output:{OUTPUT_PATH} ... <image> ... Mounts:Output={OUTPUT_PATH} |
| 199 | +``` |
| 200 | + |
| 201 | +### Get records using the container endpoints |
| 202 | + |
| 203 | +The container provides two endpoints for returning records about its usage. |
| 204 | + |
| 205 | +#### Get all records |
| 206 | + |
| 207 | +The following endpoint will provide a report summarizing all of the usage collected in the mounted billing record directory. |
| 208 | + |
| 209 | +```http |
| 210 | +https://<service>/records/usage-logs/ |
| 211 | +``` |
| 212 | + |
| 213 | +It will return JSON similar to the example below. |
| 214 | + |
| 215 | +```json |
| 216 | +{ |
| 217 | + "apiType": "noop", |
| 218 | + "serviceName": "noop", |
| 219 | + "meters": [ |
| 220 | + { |
| 221 | + "name": "Sample.Meter", |
| 222 | + "quantity": 253 |
| 223 | + } |
| 224 | + ] |
| 225 | +} |
| 226 | +``` |
| 227 | + |
| 228 | +#### Get records for a specific month |
| 229 | + |
| 230 | +The following endpoint will provide a report summarizing usage over a specific month and year. |
| 231 | + |
| 232 | +```HTTP |
| 233 | +https://<service>/records/usage-logs/{MONTH}/{YEAR} |
| 234 | +``` |
| 235 | + |
| 236 | +it will return a JSON response similar to the example below: |
| 237 | + |
| 238 | +```json |
| 239 | +{ |
| 240 | + "apiType": "string", |
| 241 | + "serviceName": "string", |
| 242 | + "meters": [ |
| 243 | + { |
| 244 | + "name": "string", |
| 245 | + "quantity": 253 |
| 246 | + } |
| 247 | + ] |
| 248 | +} |
| 249 | +``` |
| 250 | + |
| 251 | +## Purchase a different commitment plan for disconnected containers |
| 252 | + |
| 253 | +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 additional 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. |
| 254 | + |
| 255 | +You can choose a different commitment plan in the **Commitment Tier pricing** settings of your resource. |
| 256 | + |
| 257 | +## End a commitment plan |
| 258 | + |
| 259 | +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 have until midnight (UTC) on the last day of the year to end a commitment plan for disconnected containers, and not be charged for the following year. |
| 260 | + |
| 261 | +## Troubleshooting |
| 262 | + |
| 263 | +If you run the container with an output mount and logging enabled, the container generates log files that are helpful to troubleshoot issues that happen while starting or running the container. |
| 264 | + |
| 265 | +> [!TIP] |
| 266 | +> For more troubleshooting information and guidance, see [Disconnected containers Frequently asked questions (FAQ)](disconnected-container-faq.yml). |
| 267 | +
|
| 268 | +## Next steps |
| 269 | + |
| 270 | +[Azure Cognitive Services containers overview](../cognitive-services-container-support.md) |
0 commit comments