diff --git a/sdk/formrecognizer/Azure.AI.FormRecognizer/CHANGELOG.md b/sdk/formrecognizer/Azure.AI.FormRecognizer/CHANGELOG.md index 30cc58b028ec..aa7c94dea339 100644 --- a/sdk/formrecognizer/Azure.AI.FormRecognizer/CHANGELOG.md +++ b/sdk/formrecognizer/Azure.AI.FormRecognizer/CHANGELOG.md @@ -4,6 +4,8 @@ ### New Features - Updated the `FormRecognizerModelFactory` class to support missing model types for mocking. +- Added support for service version `2.0`. This can be specified in the `FormRecognizerClientOptions` object under the `ServiceVersion` enum. +By default the SDK targets latest supported service version. ### Breaking changes - Renamed `Id` for `Identity` in all the `StartRecognizeIdDocuments` functionalities. For example, the name of the method is now `StartRecognizeIdentityDocuments`. diff --git a/sdk/formrecognizer/Azure.AI.FormRecognizer/README.md b/sdk/formrecognizer/Azure.AI.FormRecognizer/README.md index ae9b6408dcf4..0d1373f66d94 100644 --- a/sdk/formrecognizer/Azure.AI.FormRecognizer/README.md +++ b/sdk/formrecognizer/Azure.AI.FormRecognizer/README.md @@ -20,6 +20,15 @@ Install the Azure Form Recognizer client library for .NET with [NuGet][nuget]: dotnet add package Azure.AI.FormRecognizer ``` +> Note: This version of the client library defaults to the `v2.1-preview.3` version of the service. + +This table shows the relationship between SDK versions and supported API versions of the service: + +|SDK version|Supported API version of service +|-|- +|3.0.0 - Latest GA release | 2.0 +|3.1.0-beta.4 - Latest release (beta)| 2.0, 2.1-preview.3 + ### Prerequisites * An [Azure subscription][azure_sub]. * An existing Cognitive Services or Form Recognizer resource. diff --git a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient.cs b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient.cs index 147e1c89b83d..393b1c024e95 100644 --- a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient.cs +++ b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient.cs @@ -448,6 +448,9 @@ public virtual RecognizeReceiptsOperation StartRecognizeReceiptsFromUri(Uri rece /// A set of options available for configuring the recognize request. For example, specify the content type of the /// form, the locale of the form, or whether or not to include form elements. /// A controlling the request lifetime. + /// + /// Method is only available for and up. + /// /// A to wait on this long-running operation. Its upon successful /// completion will contain the extracted business cards. public virtual async Task StartRecognizeBusinessCardsAsync(Stream businessCard, RecognizeBusinessCardsOptions recognizeBusinessCardsOptions = default, CancellationToken cancellationToken = default) @@ -489,6 +492,9 @@ public virtual async Task StartRecognizeBusines /// A set of options available for configuring the recognize request. For example, specify the content type of the /// form, the locale of the form, or whether or not to include form elements. /// A controlling the request lifetime. + /// + /// Method is only available for and up. + /// /// A to wait on this long-running operation. Its upon successful /// completion will contain the extracted business cards. public virtual RecognizeBusinessCardsOperation StartRecognizeBusinessCards(Stream businessCard, RecognizeBusinessCardsOptions recognizeBusinessCardsOptions = default, CancellationToken cancellationToken = default) @@ -530,6 +536,9 @@ public virtual RecognizeBusinessCardsOperation StartRecognizeBusinessCards(Strea /// A set of options available for configuring the recognize request. For example, specify the content type of the /// form, the locale of the form, or whether or not to include form elements. /// A controlling the request lifetime. + /// + /// Method is only available for and up. + /// /// A to wait on this long-running operation. Its upon successful /// completion will contain the extracted business cards. public virtual async Task StartRecognizeBusinessCardsFromUriAsync(Uri businessCardUri, RecognizeBusinessCardsOptions recognizeBusinessCardsOptions = default, CancellationToken cancellationToken = default) @@ -569,6 +578,9 @@ public virtual async Task StartRecognizeBusines /// A set of options available for configuring the recognize request. For example, specify the content type of the /// form, the locale of the form, or whether or not to include form elements. /// A controlling the request lifetime. + /// + /// Method is only available for and up. + /// /// A to wait on this long-running operation. Its upon successful /// completion will contain the extracted business cards. public virtual RecognizeBusinessCardsOperation StartRecognizeBusinessCardsFromUri(Uri businessCardUri, RecognizeBusinessCardsOptions recognizeBusinessCardsOptions = default, CancellationToken cancellationToken = default) @@ -612,6 +624,9 @@ public virtual RecognizeBusinessCardsOperation StartRecognizeBusinessCardsFromUr /// A set of options available for configuring the recognize request. For example, specify the content type of the /// form, the locale of the form, or whether or not to include form elements. /// A controlling the request lifetime. + /// + /// Method is only available for and up. + /// /// A to wait on this long-running operation. Its upon successful /// completion will contain the extracted invoices. public virtual async Task StartRecognizeInvoicesAsync(Stream invoice, RecognizeInvoicesOptions recognizeInvoicesOptions = default, CancellationToken cancellationToken = default) @@ -653,6 +668,9 @@ public virtual async Task StartRecognizeInvoicesAsyn /// A set of options available for configuring the recognize request. For example, specify the content type of the /// form, the locale of the form, or whether or not to include form elements. /// A controlling the request lifetime. + /// + /// Method is only available for and up. + /// /// A to wait on this long-running operation. Its upon successful /// completion will contain the extracted invoices. public virtual RecognizeInvoicesOperation StartRecognizeInvoices(Stream invoice, RecognizeInvoicesOptions recognizeInvoicesOptions = default, CancellationToken cancellationToken = default) @@ -694,6 +712,9 @@ public virtual RecognizeInvoicesOperation StartRecognizeInvoices(Stream invoice, /// A set of options available for configuring the recognize request. For example, specify the content type of the /// form, the locale of the form, or whether or not to include form elements. /// A controlling the request lifetime. + /// + /// Method is only available for and up. + /// /// A to wait on this long-running operation. Its upon successful /// completion will contain the extracted invoices. public virtual async Task StartRecognizeInvoicesFromUriAsync(Uri invoiceUri, RecognizeInvoicesOptions recognizeInvoicesOptions = default, CancellationToken cancellationToken = default) @@ -733,6 +754,9 @@ public virtual async Task StartRecognizeInvoicesFrom /// A set of options available for configuring the recognize request. For example, specify the content type of the /// form, the locale of the form, or whether or not to include form elements. /// A controlling the request lifetime. + /// + /// Method is only available for and up. + /// /// A to wait on this long-running operation. Its upon successful /// completion will contain the extracted invoices. public virtual RecognizeInvoicesOperation StartRecognizeInvoicesFromUri(Uri invoiceUri, RecognizeInvoicesOptions recognizeInvoicesOptions = default, CancellationToken cancellationToken = default) @@ -776,6 +800,9 @@ public virtual RecognizeInvoicesOperation StartRecognizeInvoicesFromUri(Uri invo /// A set of options available for configuring the recognize request. For example, specify the content type of the /// form, or whether or not to include form elements. /// A controlling the request lifetime. + /// + /// Method is only available for and up. + /// /// A to wait on this long-running operation. Its upon successful /// completion will contain the extracted identity document information. public virtual async Task StartRecognizeIdentityDocumentsAsync(Stream identityDocument, RecognizeIdentityDocumentsOptions recognizeIdentityDocumentsOptions = default, CancellationToken cancellationToken = default) @@ -817,6 +844,9 @@ public virtual async Task StartRecognizeIde /// A set of options available for configuring the recognize request. For example, specify the content type of the /// form, or whether or not to include form elements. /// A controlling the request lifetime. + /// + /// Method is only available for and up. + /// /// A to wait on this long-running operation. Its upon successful /// completion will contain the extracted identity document information. public virtual RecognizeIdentityDocumentsOperation StartRecognizeIdentityDocuments(Stream identityDocument, RecognizeIdentityDocumentsOptions recognizeIdentityDocumentsOptions = default, CancellationToken cancellationToken = default) @@ -858,6 +888,9 @@ public virtual RecognizeIdentityDocumentsOperation StartRecognizeIdentityDocumen /// A set of options available for configuring the recognize request. For example, specify the content type of the /// form, or whether or not to include form elements. /// A controlling the request lifetime. + /// + /// Method is only available for and up. + /// /// A to wait on this long-running operation. Its upon successful /// completion will contain the extracted identity document information. public virtual async Task StartRecognizeIdentityDocumentsFromUriAsync(Uri identityDocumentUri, RecognizeIdentityDocumentsOptions recognizeIdentityDocumentsOptions = default, CancellationToken cancellationToken = default) @@ -897,6 +930,9 @@ public virtual async Task StartRecognizeIde /// A set of options available for configuring the recognize request. For example, specify the content type of the /// form, or whether or not to include form elements. /// A controlling the request lifetime. + /// + /// Method is only available for and up. + /// /// A to wait on this long-running operation. Its upon successful /// completion will contain the extracted identity document information. public virtual RecognizeIdentityDocumentsOperation StartRecognizeIdentityDocumentsFromUri(Uri identityDocumentUri, RecognizeIdentityDocumentsOptions recognizeIdentityDocumentsOptions = default, CancellationToken cancellationToken = default) diff --git a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormTrainingClient.cs b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormTrainingClient.cs index 34715ffe3fb4..f6246709f72f 100644 --- a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormTrainingClient.cs +++ b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormTrainingClient.cs @@ -288,6 +288,9 @@ public virtual async Task StartTrainingAsync(Uri trainingFile /// List of model ids to use in the composed model. /// An optional, user-defined name to associate with the model. /// A controlling the request lifetime. + /// + /// Method is only available for and up. + /// /// /// A to wait on this long-running operation. Its Value upon successful /// completion will contain meta-data about the composed model. @@ -326,6 +329,9 @@ public virtual CreateComposedModelOperation StartCreateComposedModel(IEnumerable /// List of model ids to use in the composed model. /// An optional, user-defined name to associate with the model. /// A controlling the request lifetime. + /// + /// Method is only available for and up. + /// /// /// A to wait on this long-running operation. Its Value upon successful /// completion will contain meta-data about the composed model. diff --git a/sdk/formrecognizer/Azure.AI.FormRecognizer/tests/FormRecognizerClient/FormRecognizerClientLiveTests.cs b/sdk/formrecognizer/Azure.AI.FormRecognizer/tests/FormRecognizerClient/FormRecognizerClientLiveTests.cs index eeb3544b7642..d11bb954dd46 100644 --- a/sdk/formrecognizer/Azure.AI.FormRecognizer/tests/FormRecognizerClient/FormRecognizerClientLiveTests.cs +++ b/sdk/formrecognizer/Azure.AI.FormRecognizer/tests/FormRecognizerClient/FormRecognizerClientLiveTests.cs @@ -42,5 +42,38 @@ public void FormRecognizerClientCannotAuthenticateWithFakeApiKey() Assert.ThrowsAsync(async () => await client.StartRecognizeContentAsync(stream)); } } + + [RecordedTest] + [ServiceVersion(Max = FormRecognizerClientOptions.ServiceVersion.V2_0)] + public void StartRecognizeBusinessCardsWithV2() + { + var client = CreateFormRecognizerClient(); + var uri = FormRecognizerTestEnvironment.CreateUri(TestFile.BusinessCardJpg); + + RequestFailedException ex = Assert.ThrowsAsync(async () => await client.StartRecognizeBusinessCardsFromUriAsync(uri)); + Assert.AreEqual("404", ex.ErrorCode); + } + + [RecordedTest] + [ServiceVersion(Max = FormRecognizerClientOptions.ServiceVersion.V2_0)] + public void StartRecognizeIdentityDocumentsWithV2() + { + var client = CreateFormRecognizerClient(); + var uri = FormRecognizerTestEnvironment.CreateUri(TestFile.DriverLicenseJpg); + + RequestFailedException ex = Assert.ThrowsAsync(async () => await client.StartRecognizeIdentityDocumentsFromUriAsync(uri)); + Assert.AreEqual("404", ex.ErrorCode); + } + + [RecordedTest] + [ServiceVersion(Max = FormRecognizerClientOptions.ServiceVersion.V2_0)] + public void StartRecognizeInvoicesWithV2() + { + var client = CreateFormRecognizerClient(); + var uri = FormRecognizerTestEnvironment.CreateUri(TestFile.InvoiceJpg); + + RequestFailedException ex = Assert.ThrowsAsync(async () => await client.StartRecognizeInvoicesFromUriAsync(uri)); + Assert.AreEqual("404", ex.ErrorCode); + } } } diff --git a/sdk/formrecognizer/Azure.AI.FormRecognizer/tests/FormTrainingClient/FormTrainingClientLiveTests.cs b/sdk/formrecognizer/Azure.AI.FormRecognizer/tests/FormTrainingClient/FormTrainingClientLiveTests.cs index e1049eff21a7..b24e1e7f5152 100644 --- a/sdk/formrecognizer/Azure.AI.FormRecognizer/tests/FormTrainingClient/FormTrainingClientLiveTests.cs +++ b/sdk/formrecognizer/Azure.AI.FormRecognizer/tests/FormTrainingClient/FormTrainingClientLiveTests.cs @@ -134,6 +134,21 @@ public async Task CheckFormTypeinSubmodelAndRecognizedForm(bool labeled) Assert.AreEqual(form.FormType, model.Submodels.FirstOrDefault().FormType); } + [RecordedTest] + [ServiceVersion(Max = FormRecognizerClientOptions.ServiceVersion.V2_0)] + public async Task StartCreateComposedModelWithV2() + { + var client = CreateFormTrainingClient(); + + await using var trainedModelA = await CreateDisposableTrainedModelAsync(useTrainingLabels: true); + await using var trainedModelB = await CreateDisposableTrainedModelAsync(useTrainingLabels: true); + + var modelIds = new List { trainedModelA.ModelId, trainedModelB.ModelId }; + + RequestFailedException ex = Assert.ThrowsAsync(async () => await client.StartCreateComposedModelAsync(modelIds)); + Assert.AreEqual("404", ex.ErrorCode); + } + [RecordedTest] [TestCase(false)] [TestCase(true)]