Unable to copy a custom trained Form Recognizer model using the "azure-sdk-for-net" version 4.0.0

Luthando Mntonga 0 Reputation points
2023-03-17T11:51:27.6366667+00:00

I am currently using the azure-sdk-for-net readme as a reference to try and promote a trained model to production. The trained model seems to be in a good state in the development environment. The model was trained using the api version 2022-08-31

Running a operation call and getdocumentmodel, indicates that the custom model has been created successfully with a status "Succeeded" as highlighted below.

GeOperation
Operations Proof

GetDocumentModel
User's image

Where the issue starts is when making the calls to destination DocumentModelAdministrationClient, the GetCopyAuthorization works fine, returning the "DocumentModelCopyAuthorization" as expected. When making a call to the CopyDocumentModelTo, I am getting an error "ModelNotReady"

User's image

When I return the GetCopyAuthorization after the first call fails, I get an error that the "ModelExists". This happens despite the "target" models document client GetDocumentModels doesn't return the model in question. Below is the error I am getting on the copy authorization:

User's image

Azure AI Document Intelligence
Azure AI Document Intelligence
An Azure service that turns documents into usable data. Previously known as Azure Form Recognizer.
1,365 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,369 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Luthando Mntonga 0 Reputation points
    2023-03-22T08:32:39.0933333+00:00

    Hi @YutongTie-MSFT so it turns out this is a non issue. There was actually a bug on my code. I was attempting to run the "CopyDocumentModelTo" against the target client instead of the source client.

    My code looked like this:

    var targetAuthorizationCopy = _targetModelClient.GetCopyAuthorization(sourceModel.ModelId);
                        var copyModelToTarget = 
    _targetModelClient.CopyDocumentModelTo(Azure.WaitUntil.Completed, sourceModel.ModelId, targetAuthorizationCopy);
    

    It is actually meant to look like this:

    var targetAuthorizationCopy = _targetModelClient.GetCopyAuthorization(sourceModel.ModelId);
                        var copyModelToTarget = _sourceModelClient.CopyDocumentModelTo(Azure.WaitUntil.Completed, sourceModel.ModelId, targetAuthorizationCopy);