Azure

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.

  1. Goal Endpoint
    Get it from Goal Type Recognizer app>Useful resource Administration>Keys and Endpoint>Endpoint
  2. Goal Subscription Key
    Get it from Goal Type Recognizer app>Useful resource Administration>Keys and Endpoint>Key or Key 2
  3. Goal Useful resource Id
    Get it from Goal Type Recognizer app>Useful resource Administration>Properties>Useful resource Id
  4. Goal Useful resource Area
    Get it from Goal Type Recognizer app>Useful resource Administration>Keys and Endpoint>Location
  5. Supply Endpoint
    Get it from Supply Type Recognizer app>Useful resource Administration>Keys and Endpoint>Endpoint
  6. 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,

 

x-envoy-upstream-service-time: 364
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

  1. {  
  2.     “modelList”: [{  
  3.         “modelId”“00a7a4ac-abc4-23ds-234r-366cc364e2c2”,  
  4.         “modelName”“GV”,  
  5.         “attributes”: {  
  6.             “isComposed”true  
  7.         },  
  8.         “status”“ready”,  
  9.         “createdDateTime”“2020-09-27T18:38:29Z”,  
  10.         “lastUpdatedDateTime”“2020-09-27T18:38:30Z”  
  11.     }, {  
  12.         “modelId”“01d3ccef-c987-4689-123f-65be2860c25e”,  
  13.         “modelName”“AV”,  
  14.         “attributes”: {  
  15.             “isComposed”false  
  16.         },  
  17.         “status”“ready”,  
  18.         “createdDateTime”“2020-11-03T17:32:54Z”,  
  19.         “lastUpdatedDateTime”“2020-11-03T17:32:59Z”  
  20.     }],  
  21.     “nextLink”“https://xxxx.api.cognitive.microsoft.com/formrecognizer/v2.1-preview.1/customized/fashions?nextLink=2!204!MTJmYmQ0ZjJjOTFhYiY0Mi1iMjhjkxMGMvbW991OS45OTk5OTk5WiEDAwMTA4IXN1YnNjcmlwdGlvbjghOTk1c2VMYWJlbEZpbGUuanNvbiEwMDAwMOTo5OS0xMi0zMVQyMzo1nMvMTU1NTVjNWEzMTA3NGZjN2FlZWM1MGQ0YjY4MU3Mzg0NGQ2LWY3MjItNGkZWxzLzkL-“  
  22. }  

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,

 

x-envoy-upstream-service-time: 32
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

  1. {  
  2.     “modelId”“85f23761-1234-3423-dsef-kfrd648a65c3”,  
  3.     “accessToken”“a1b3119a-fred-4312-5643-gtrk33410737”,  
  4.     “expirationDateTimeTicks”: 1619123456  
  5. }  

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.

  1. {  
  2.     “targetResourceId”“{Goal Useful resource Id}”,  
  3.     “targetResourceRegion”“{Goal Useful resource Area}”,  
  4.     “copyAuthorization”: {  
  5.         “modelId”“85f23761-1234-3423-dsef-kfrd648a65c3”,  
  6.         “accessToken”“a1b3119a-fred-4312-5643-gtrk33410737”,  
  7.         “expirationDateTimeTicks”: 1619123456  
  8.     }  
  9. }  

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

 

The operation of copy a customized mannequin from one subscription / tenant would achieve success by following the procedures above. You might discover official documentation of the above API’s by clicking right here. There are additionally two extra API’s Get Customized Mannequin and Get Copy Mannequin Consequence which can allow you to higher.

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button