Copy/Migrate Azure Type Recognizer Customized Mannequin To Different Subscription/Tenant
Introduction
This text guides you thru the steps on how we might copy or migrate a Azure Cognitive Service Type Recognizer Customized Skilled Mannequin from one subscription or tenant to different. We are able to attain the above utilizing three API calls thus will be carried out programmatically utilizing script.
Earlier than going to the API’s allow us to outline what are the issues we’d like as pre requisites. Supply is the Type Recognizer app which presently holds the mannequin. Vacation spot is the Type Recognizer app which we wish the mannequin to be copied/migrated to. When you’ve got not created the vacation spot app create it and earlier than going to the following steps.
- Goal Endpoint
Get it from Goal Type Recognizer app>Useful resource Administration>Keys and Endpoint>Endpoint - Goal Subscription Key
Get it from Goal Type Recognizer app>Useful resource Administration>Keys and Endpoint>Key or Key 2 - Goal Useful resource Id
Get it from Goal Type Recognizer app>Useful resource Administration>Properties>Useful resource Id - Goal Useful resource Area
Get it from Goal Type Recognizer app>Useful resource Administration>Keys and Endpoint>Location - Supply Endpoint
Get it from Supply Type Recognizer app>Useful resource Administration>Keys and Endpoint>Endpoint - Supply Subscription Key
Get it from Supply Type Recognizer app>Useful resource Administration>Keys and Endpoint>Key or Key 2
We might break down the entire course of into 4 steps for easiness primarily based on 4 API’s used.
Step 0 – Get present Mannequin Id of customized mannequin
This step is known as step zero as we will skip this step if we already know the mannequin id. We are able to get the mannequin id utilizing an API name (HTTP GET request).
Request URL
https://{Supply Endpoint}/formrecognizer/v2.1-preview.1/customized/fashions?op=full
Header
Ocp-Apim-Subscription-Key : {Supply Subscription Key}
By doing the above API name we are going to get a JSON outcome with the checklist of all customized fashions within the Supply Type Recognizer app. Discover the mannequin id you want by the mannequin title you will have given throughout coaching section of customized mannequin.
A pattern of the result’s given under,
apim-request-id: 77cbd3cc-a2bc-4132-b456-1501e8e621e1
Strict-Transport-Safety: max-age=31536000; includeSubDomains; preload
x-content-type-options: nosniff
Date: Fri, 23 Apr 2021 09:53:50 GMT
Content material-Size: 5967
Content material-Kind: software/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/customized/fashions?nextLink=2!204!MTJmYmQ0ZjJjOTFhYiY0Mi1iMjhjkxMGMvbW991OS45OTk5OTk5WiEDAwMTA4IXN1YnNjcmlwdGlvbjghOTk1c2VMYWJlbEZpbGUuanNvbiEwMDAwMOTo5OS0xMi0zMVQyMzo1nMvMTU1NTVjNWEzMTA3NGZjN2FlZWM1MGQ0YjY4MU3Mzg0NGQ2LWY3MjItNGkZWxzLzkL-“
- }
Now we have now our seventh pre requisite ie; Mannequin Id.
Step 1 – Generate Copy Authorization
We have to get the copy authorization from goal Type Recognizer app which we will likely be a JSON string with new modelId , accessToken and expirationDateTimeTicks. To generate this we will likely be doing an API name (HTTP POST Request).
Request URL
https://{Goal Endpoint}/formrecognizer/v2.1-preview.1/customized/fashions/copyAuthorization
Header
Ocp-Apim-Subscription-Key : {Goal Subscription Key}
By doing the above API name we are going to get a JSON outcome with new modelId , accessToken and expirationDateTimeTicks.
A pattern of the result’s given under,
apim-request-id: a1b3119a-fred-4312-5643-gtrk33410737
Strict-Transport-Safety: max-age=31536000; includeSubDomains; preload
x-content-type-options: nosniff
Date: Fri, 23 Apr 2021 09:50:51 GMT
Location: https://xxxx.api.cognitive.microsoft.com/formrecognizer/v2.1-preview.1/customized/fashions/85f23761-1234-3423-dsef-kfrd648a65c3
Content material-Size: 140
Content material-Kind: software/json; charset=utf-8
- {
- “modelId”: “85f23761-1234-3423-dsef-kfrd648a65c3”,
- “accessToken”: “a1b3119a-fred-4312-5643-gtrk33410737”,
- “expirationDateTimeTicks”: 1619123456
- }
Copy the worth between the curly braces to stick on POST Request physique we do in subsequent step.
Step 2 – Copy Mannequin
We now have copy authorization and required particulars with us to do the method of copying mannequin. We might do it with an API name(HTTP POST Request).
Request URL
https://{Supply Endpoint}/formrecognizer/v2.1-preview.1/customized/fashions/{Mannequin Id}/copy
Header
Content material-Kind: software/json
Ocp-Apim-Subscription-Key : {Supply Subscription Key}
Request Physique: Copy the values between curly braces from results of step 1 and paste the worth as worth of copyAuthorization within the under request.
- {
- “targetResourceId”: “{Goal Useful resource Id}”,
- “targetResourceRegion”: “{Goal Useful resource Area}”,
- “copyAuthorization”: {
- “modelId”: “85f23761-1234-3423-dsef-kfrd648a65c3”,
- “accessToken”: “a1b3119a-fred-4312-5643-gtrk33410737”,
- “expirationDateTimeTicks”: 1619123456
- }
- }
By doing the above API name we are going to get a response with 202 standing which signifies request is accepted. You might repeat the step Zero with goal credentials to know the brand new Mannequin Id and standing of copying. You possibly can cease right here in case your goal solely was to repeat the mannequin.
Step 3 – Delete Mannequin
This step will not be obligatory, It’s best to do it provided that that you must delete the mannequin from Supply.
We might delete the customized mannequin from Supply Type Recognizer app utilizing Supply credentials by a API Name (HTTP DELETE Request).
Request URL
https://{Supply Endpoint}/formrecognizer/v2.1-preview.1/customized/fashions/{Mannequin Id}
Header
Ocp-Apim-Subscription-Key : {Supply Subscription Key}
A response with standing code 204 says the operation was profitable and the operation will atke round 48 hours to finish motion.
Conclusion