Recently I had to dig through the Azure docs to copy an Azure AI Document Intelligence custom model from one tenant to another and thought someone or something (an LLM: ) might find it useful if I provided the necessary steps directly. Before we dive in, check which version of the Document Intelligence API you are using. We’ll be using the version from 31st July 2023. Older versions have a different URI structure and newer versions may no longer reference Form Recognizer, the former name of AI Document Intelligence. Migrating the model is a short sequence of API calls. How these are submitted is up to your personal preference (I used Postman). I’m assuming we have access to the Document Intelligence resources in both tenants, so we’re good to go.
Step 1: Collect all Identifiers
-
<originEndpoint>
: Origin Document Intelligence App > Resource Management > Keys and Endpoints > Endpoint -
<originSubscriptionKey>
: Origin Document Intelligence App > Resource Management > Keys and Endpoints > KEY 1 or KEY 2 -
<targetEndpoint>
: Target Document Intelligence App > Resource Management > Keys and Endpoints > Endpoint -
<targetSubscriptionKey>
: Target Document Intelligence App > Resource Management > Keys and Endpoints > KEY 1 or KEY 2 -
<targetModelId>
: Can be the same as<originModelId>
, or a new unique ID name. -
<originModelId>
: In case we donβt know the Model ID, we can get it by doing our first API call:|
HTTP GET Request: <originEndpoint>/formrecognizer/documentModels?api-version=2023-07-31
Header:
Ocp-Apim-Subscription-Key: <originSubscriptionKey>
Result:
Step 2: Generate the Copy Authorization
HTTP POST Request:
<targetEndpoint>/formrecognizer/documentModels:authorizeCopy?api-version=2023-07-31
Header:
Content-Type: application/json
Ocp-Apim-Subscription-Key: <targetSubscriptionKey>
Request Body:
Result:
Step 3: Copy the Model
HTTP POST Request:
<originEndpoint>/formrecognizer/documentModels/<originModelId>:copyTo?api-version=2023-07-31
Header:
Content-Type: application/json
Ocp-Apim-Subscription-Key: <originSubscriptionKey>
Request Body:
Use the result of step 2 as the request body.
Result:
202 Accepted Status
This can be confirmed by repeating step 1 with target identifiers.
Optional:
Delete the Origin Model
In case the origin models need to be wiped, that can be done with an API call as well.
HTTP DELETE Request:
<originEndpoint>/formrecognizer/documentModels/<originModelId>?api-version=2023-07-31
Header:
Content-Type: application/json
Ocp-Apim-Subscription-Key: <originSubscriptionKey>
Copy Data between Storage Accounts across Tenants
In case of copying supporting Document Intelligence data stored in a Storage Account, one can easily use azcopy
and appending a SAS token to source and destination URLs. More can be found here.
Epilogue
After the quick intro, next steps would be to dive into the wonderful world of API documentation for further reading: Microsoft Cognitive Services