Document Intelligence Studio | deploy / import models with CI/CD
I am looking to deploy a Document Intelligence Studio resource and I wish to be able to import a pre-trained Custom Extraction Model into the newly deployed resource as part of an automated CI/CD pipeline.
How would I do this?
Thanks!
Azure AI Document Intelligence
-
kothapally Snigdha • 1,620 Reputation points • Microsoft Vendor
2025-02-13T23:06:17.2566667+00:00 Hi Richard Jackson,
To deploy a Document Intelligence Studio resource and import a pre-trained Custom Extraction Model as part of an automated CI/CD pipeline, you can follow these steps:
- Ensure you have an Azure subscription and create a Document Intelligence instance in the Azure portal.
- Import the Custom Extraction Model:
- Navigate to the Document Intelligence Studio.
- Select the Custom extraction models tile under the custom models' section.
- Click on the Import button on the custom extraction model's page.
- In the import project dialog, paste the project token of the pre-trained model that you wish to import and select import.
I hope these helps you. Thank you!
-
Richard Jackson • 71 Reputation points
2025-02-14T09:03:23.4833333+00:00 [accidental duplicate - comment to be deleted]
-
Richard Jackson • 71 Reputation points
2025-02-14T09:35:34.7833333+00:00 Hi @kothapally Snigdha Thanks for your response. Those are the two steps required, and you've described the manual processes. I am looking to automate them as part of a CI/CD pipeline.
- Ensure you have an Azure subscription and create a Document Intelligence instance in the Azure portal.
I have used a Bicep file within an Azure DevOps pipeline to do this.
- Import the Custom Extraction Model
This the focus of my question - how would one automate these steps? Even if I could provide the Project Token of the Custom Extraction Model as an environment variable, how could I automate the "Import" step?
Thanks!
Rich
-
kothapally Snigdha • 1,620 Reputation points • Microsoft Vendor
2025-02-19T13:53:11.8666667+00:00 Hi Richard Jackson,
Sorry for Delay
To automate the import of your pre-trained Custom Extraction Model into Document Intelligence Studio as part of your CI/CD pipeline, here's are some steps.
- You've already deployed the Document Intelligence Studio resource using your Bicep file, which is great!
- For automating the import of the pre-trained model, you'll need to use Azure CLI and the Form Recognizer REST API in your pipeline. Here's a simple breakdown:
- First, store the Project Token of the model as an environment variable in your pipeline.
- Then, use Azure CLI to authenticate and get an access token.
- Finally, make a POST request using curl to import the model into your Document Intelligence Studio resource.
I’ve put together a quick pipeline script example to help you automate this:
jobs: - job: DeployAndImportModel pool: vmImage: 'ubuntu-latest' steps: - task: AzureCLI@2 inputs: azureSubscription: '<AzureSubscriptionName>' # Your Azure subscription name scriptType: 'bash' scriptLocation: 'inlineScript' inlineScript: | # Get Azure Access Token ACCESS_TOKEN=$(az account get-access-token --query accessToken --output tsv) # Set your resource name and the project token (from environment variable) RESOURCE_NAME="<YourResourceName>" # Your Document Intelligence resource name PROJECT_TOKEN="$PRETRAINED_PROJECT_TOKEN" # The pre-trained model's token # Make the API call to import the model curl -X POST "https://$RESOURCE_NAME.cognitiveservices.azure.com/formrecognizer/v2.0/custom/models/import" \ -H "Authorization: Bearer $ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d "{ \"projectToken\": \"$PROJECT_TOKEN\" }"
This script will authenticate to Azure, grab the access token, and then automatically import the model into your resource using the Project Token you've stored in your pipeline. I hope these helps you. Thank you!
-
Richard Jackson • 71 Reputation points
2025-02-19T14:35:30.63+00:00 That looks perfect, I'll check this out and report back. Thank you so much for the direction!
Rich
-
Richard Jackson • 71 Reputation points
2025-02-19T14:46:18.9466667+00:00 @kothapally Snigdha
You mention the "https://$RESOURCE_NAME.cognitiveservices.azure.com/formrecognizer/v2.0/custom/models/import" endpoint but I can't find any documentation about this. Would you mind providing a source for this please? -
kothapally Snigdha • 1,620 Reputation points • Microsoft Vendor
2025-02-21T17:54:43.8066667+00:00 Hi Richard Jackson,
This URL is for Microsoft's Form Recognizer service, part of Azure Cognitive Services, and it's used to import custom models.
- https: Secure HTTPS protocol.
- $RESOURCE_NAME**:** Placeholder for your Azure resource name.
- cognitiveservices.azure.com: Domain for Azure Cognitive Services.
- form recognizer/v2.0/custom/models/import: Form Recognizer service, version 2.0, custom models, and the import function.
Just replace $RESOURCE_NAME with your actual resource name to access the endpoint for importing custom models into the Form Recognizer service.
I hope these helps you. Thank you!
-
kothapally Snigdha • 1,620 Reputation points • Microsoft Vendor
2025-02-24T17:04:42.36+00:00 Hi Richard Jackson,
Following up to see the response was helpful.
-
Richard Jackson • 71 Reputation points
2025-02-25T23:41:39.51+00:00 Sorry for the delay, I'll be trying this out next week - however, crucially, you have yet to link me with any documentation to back-up your claims. Without sources, you could have just copied/pasted from generative AI. Please could you link me to where in the documentation that URL is mentioned?
Thank you
Sign in to comment