Introduction
This article guides you through the steps on how we could copy or migrate a Azure Cognitive Service Form Recognizer Custom Trained Model from one subscription or tenant to other. We can attain the above using three API calls thus can be done programmatically using script.
Before going to the API's let us define what are the things we need as pre requisites. Source is the Form Recognizer app which currently holds the model. Destination is the Form Recognizer app which we want the model to be copied/migrated to. If you have not created the destination app create it and before going to the next steps.
- Target Endpoint
Get it from Target Form Recognizer app>Resource Management>Keys and Endpoint>Endpoint - Target Subscription Key
Get it from Target Form Recognizer app>Resource Management>Keys and Endpoint>Key or Key 2 - Target Resource Id
Get it from Target Form Recognizer app>Resource Management>Properties>Resource Id - Target Resource Region
Get it from Target Form Recognizer app>Resource Management>Keys and Endpoint>Location - Source Endpoint
Get it from Source Form Recognizer app>Resource Management>Keys and Endpoint>Endpoint - Source Subscription Key
Get it from Source Form Recognizer app>Resource Management>Keys and Endpoint>Key or Key 2
We could break down the whole process into four steps for easiness based on four API's used.
Step 0 - Get current Model Id of custom model
This step is named step zero as we can skip this step if we already know the model id. We can get the model id using an API call (HTTP GET request).
Request URL
https://{Source Endpoint}/formrecognizer/v2.1-preview.1/custom/models?op=full
Header
Ocp-Apim-Subscription-Key : {Source Subscription Key}
By doing the above API call we will get a JSON result with the list of all custom models in the Source Form Recognizer app. Find the model id you need by the model name you have given during training phase of custom model.
A sample of the result is given below,
x-envoy-upstream-service-time: 364
apim-request-id: 77cbd3cc-a2bc-4132-b456-1501e8e621e1
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
x-content-type-options: nosniff
Date: Fri, 23 Apr 2021 09:53:50 GMT
Content-Length: 5967
Content-Type: application/json; charset=utf-8
apim-request-id: 77cbd3cc-a2bc-4132-b456-1501e8e621e1
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
x-content-type-options: nosniff
Date: Fri, 23 Apr 2021 09:53:50 GMT
Content-Length: 5967
Content-Type: application/json; charset=utf-8
- {
- "modelList": [{
- "modelId": "00a7a4ac-abc4-23ds-234r-366cc364e2c2",
- "modelName": "GV",
- "attributes": {
- "isComposed": true
- },
- "status": "ready",
- "createdDateTime": "2020-09-27T18:38:29Z",
- "lastUpdatedDateTime": "2020-09-27T18:38:30Z"
- }, {
- "modelId": "01d3ccef-c987-4689-123f-65be2860c25e",
- "modelName": "AV",
- "attributes": {
- "isComposed": false
- },
- "status": "ready",
- "createdDateTime": "2020-11-03T17:32:54Z",
- "lastUpdatedDateTime": "2020-11-03T17:32:59Z"
- }],
- "nextLink": "https://xxxx.api.cognitive.microsoft.com/formrecognizer/v2.1-preview.1/custom/models?nextLink=2!204!MTJmYmQ0ZjJjOTFhYiY0Mi1iMjhjkxMGMvbW991OS45OTk5OTk5WiEDAwMTA4IXN1YnNjcmlwdGlvbjghOTk1c2VMYWJlbEZpbGUuanNvbiEwMDAwMOTo5OS0xMi0zMVQyMzo1nMvMTU1NTVjNWEzMTA3NGZjN2FlZWM1MGQ0YjY4MU3Mzg0NGQ2LWY3MjItNGkZWxzLzkL-"
- }

Join the conversation! Your thoughts help the community grow.