Recently I had to dig through the Azure docs to copy an Azure AI Doc­u­ment Intel­li­gence cus­tom model from one ten­ant to another and thought someone or some­thing might find it use­ful if I provided the neces­sary steps dir­ectly. Before we dive in, check which ver­sion of the Doc­u­ment Intel­li­gence API you are using. We’ll be using the ver­sion from 31st July 2023. Older ver­sions have a dif­fer­ent URI struc­ture and newer ver­sions may no longer ref­er­ence Form Recog­nizer, the former name of AI Doc­u­ment Intel­li­gence. Migrat­ing the model is a short sequence of API calls. How these are sub­mit­ted is up to your per­sonal pref­er­ence (I used Post­man). I’m assum­ing we have access to the Doc­u­ment Intel­li­gence resources in both ten­ants, so we’re good to go.

Step 1: Col­lect all Identifiers

  1. <originEndpoint>Ori­gin Doc­u­ment Intel­li­gence App > Resource Man­age­ment > Keys and End­points > Endpoint
  2. <originSubscriptionKey>: Ori­gin Doc­u­ment Intel­li­gence App > Resource Man­age­ment > Keys and End­points > KEY 1 or KEY 2
  3. <targetEndpoint>Tar­get Doc­u­ment Intel­li­gence App > Resource Man­age­ment > Keys and End­points > Endpoint
  4. <targetSubscriptionKey>Tar­get Doc­u­ment Intel­li­gence App > Resource Man­age­ment > Keys and End­points > KEY 1 or KEY 2
  5. <targetModelId>: Can be the same as <originModelId>, or a new unique ID name.
  6. <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>

Res­ult:

Resulting code of Step 1: Collect all Identifiers

Step 2: Gen­er­ate 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:

Request Body of Step 2: Generate the Copy Authorization

Res­ult:

Resulting Code of Step 2: Generate the Copy Authorization

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 res­ult of step 2 as the request body.

Res­ult:
202 Accepted Status
This can be con­firmed by repeat­ing step 1 with tar­get identifiers.

Optional:

Delete the Ori­gin Model

In case the ori­gin mod­els 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 Stor­age Accounts across Tenants

In case of copy­ing sup­port­ing Doc­u­ment Intel­li­gence data stored in a Stor­age Account, one can eas­ily use azcopy and append­ing a SAS token to source and des­tin­a­tion URLs. More can be found here.

Epi­logue

After the quick intro, next steps would be to dive into the won­der­ful world of API doc­u­ment­a­tion for fur­ther read­ing: Microsoft Cog­nit­ive Services