public void DeleteModelArgumentValidation() { FormTrainingClient client = CreateInstrumentedClient(); Assert.ThrowsAsync <ArgumentNullException>(() => client.DeleteModelAsync(null)); Assert.ThrowsAsync <ArgumentException>(() => client.DeleteModelAsync(string.Empty)); Assert.ThrowsAsync <ArgumentException>(() => client.DeleteModelAsync("1975-04-04")); }
public async Task ManageCustomModelsAsync() { string endpoint = TestEnvironment.Endpoint; string apiKey = TestEnvironment.ApiKey; string trainingFileUrl = TestEnvironment.BlobContainerSasUrl; #region Snippet:FormRecognizerSampleManageCustomModelsAsync FormTrainingClient client = new FormTrainingClient(new Uri(endpoint), new AzureKeyCredential(apiKey)); // Check number of models in the FormRecognizer account, and the maximum number of models that can be stored. AccountProperties accountProperties = await client.GetAccountPropertiesAsync(); Console.WriteLine($"Account has {accountProperties.CustomModelCount} models."); Console.WriteLine($"It can have at most {accountProperties.CustomModelLimit} models."); // List the models currently stored in the account. AsyncPageable <CustomFormModelInfo> models = client.GetCustomModelsAsync(); await foreach (CustomFormModelInfo modelInfo in models) { Console.WriteLine($"Custom Model Info:"); Console.WriteLine($" Model Id: {modelInfo.ModelId}"); Console.WriteLine($" Model name: {modelInfo.ModelName}"); Console.WriteLine($" Is composed model: {modelInfo.Properties.IsComposedModel}"); Console.WriteLine($" Model Status: {modelInfo.Status}"); Console.WriteLine($" Training model started on: {modelInfo.TrainingStartedOn}"); Console.WriteLine($" Training model completed on: : {modelInfo.TrainingCompletedOn}"); } // Create a new model to store in the account CustomFormModel model = await client.StartTrainingAsync(new Uri(trainingFileUrl), useTrainingLabels : false, new TrainingOptions() { ModelName = "My new model" }).WaitForCompletionAsync(); // Get the model that was just created CustomFormModel modelCopy = await client.GetCustomModelAsync(model.ModelId); Console.WriteLine($"Custom Model with Id {modelCopy.ModelId} and name {modelCopy.ModelName} recognizes the following form types:"); foreach (CustomFormSubmodel submodel in modelCopy.Submodels) { Console.WriteLine($"Submodel Form Type: {submodel.FormType}"); foreach (CustomFormModelField field in submodel.Fields.Values) { Console.Write($" FieldName: {field.Name}"); if (field.Label != null) { Console.Write($", FieldLabel: {field.Label}"); } Console.WriteLine(""); } } // Delete the model from the account. await client.DeleteModelAsync(model.ModelId); #endregion }
public async Task RecognizeCustomFormsFromUri() { string endpoint = TestEnvironment.Endpoint; string apiKey = TestEnvironment.ApiKey; string trainingFileUrl = TestEnvironment.BlobContainerSasUrl; // Firstly, create a trained model we can use to recognize the custom form. Please note that // models can also be trained using a graphical user interface such as the Form Recognizer // Labeling Tool found here: // https://docs.microsoft.com/azure/cognitive-services/form-recognizer/quickstarts/label-tool FormTrainingClient trainingClient = new FormTrainingClient(new Uri(endpoint), new AzureKeyCredential(apiKey)); CustomFormModel model = await trainingClient.StartTrainingAsync(new Uri(trainingFileUrl), useTrainingLabels : false, "My Model").WaitForCompletionAsync(); // Proceed with the custom form recognition. FormRecognizerClient client = new FormRecognizerClient(new Uri(endpoint), new AzureKeyCredential(apiKey)); #region Snippet:FormRecognizerSampleRecognizeCustomFormsFromUri #if SNIPPET string modelId = "<modelId>"; Uri formUri = < formUri >; #else Uri formUri = FormRecognizerTestEnvironment.CreateUri("Form_1.jpg"); string modelId = model.ModelId; #endif RecognizeCustomFormsOperation operation = await client.StartRecognizeCustomFormsFromUriAsync(modelId, formUri); Response <RecognizedFormCollection> operationResponse = await operation.WaitForCompletionAsync(); RecognizedFormCollection forms = operationResponse.Value; foreach (RecognizedForm form in forms) { Console.WriteLine($"Form of type: {form.FormType}"); if (form.FormTypeConfidence.HasValue) { Console.WriteLine($"Form type confidence: {form.FormTypeConfidence.Value}"); } Console.WriteLine($"Form was analyzed with model with ID: {form.ModelId}"); foreach (FormField field in form.Fields.Values) { Console.WriteLine($"Field '{field.Name}': "); if (field.LabelData != null) { Console.WriteLine($" Label: '{field.LabelData.Text}'"); } Console.WriteLine($" Value: '{field.ValueData.Text}'"); Console.WriteLine($" Confidence: '{field.Confidence}'"); } } #endregion // Delete the model on completion to clean environment. await trainingClient.DeleteModelAsync(model.ModelId); }
public async Task TrainModelWithFormsAndLabels() { string endpoint = TestEnvironment.Endpoint; string apiKey = TestEnvironment.ApiKey; #region Snippet:FormRecognizerSampleTrainModelWithFormsAndLabels // For this sample, you can use the training forms found in the `trainingFiles` folder. // Upload the forms to your storage container and then generate a container SAS URL. Note // that a container URI without SAS is accepted only when the container is public or has a // managed identity configured. // // For instructions to set up forms for training in an Azure Blob Storage Container, please see: // https://docs.microsoft.com/azure/cognitive-services/form-recognizer/build-training-data-set#upload-your-training-data // For instructions to create a label file for your training forms, please see: // https://docs.microsoft.com/azure/cognitive-services/form-recognizer/label-tool?tabs=v2-1 #if SNIPPET Uri trainingFileUri = new Uri("<trainingFileUri>"); #else Uri trainingFileUri = new Uri(TestEnvironment.BlobContainerSasUrlV2); #endif string modelName = "My Model with labels"; FormTrainingClient client = new FormTrainingClient(new Uri(endpoint), new AzureKeyCredential(apiKey)); TrainingOperation operation = await client.StartTrainingAsync(trainingFileUri, useTrainingLabels : true, modelName); Response <CustomFormModel> operationResponse = await operation.WaitForCompletionAsync(); CustomFormModel model = operationResponse.Value; Console.WriteLine($"Custom Model Info:"); Console.WriteLine($" Model Id: {model.ModelId}"); Console.WriteLine($" Model name: {model.ModelName}"); Console.WriteLine($" Model Status: {model.Status}"); Console.WriteLine($" Is composed model: {model.Properties.IsComposedModel}"); Console.WriteLine($" Training model started on: {model.TrainingStartedOn}"); Console.WriteLine($" Training model completed on: {model.TrainingCompletedOn}"); foreach (CustomFormSubmodel submodel in model.Submodels) { Console.WriteLine($"Submodel Form Type: {submodel.FormType}"); foreach (CustomFormModelField field in submodel.Fields.Values) { Console.Write($" FieldName: {field.Name}"); if (field.Accuracy != null) { Console.Write($", Accuracy: {field.Accuracy}"); } Console.WriteLine(""); } } #endregion // Delete the model on completion to clean environment. await client.DeleteModelAsync(model.ModelId); }
private static async Task AnalyzeDynamicCustomForm(FormRecognizerClient recognizerClient, string trainingFileUrl, string formUrl) { RecognizeCustomFormsOptions options = new RecognizeCustomFormsOptions(); //train model FormTrainingClient trainingClient = new FormTrainingClient(new Uri(endpoint), new AzureKeyCredential(apiKey)); CustomFormModel model = await trainingClient.StartTrainingAsync(new Uri(trainingFileUrl), useTrainingLabels : false, $"VIS-Dynamic-Model-{DateTime.Now.ToShortDateString()}-{DateTime.Now.ToLongTimeString()}").WaitForCompletionAsync(); //string modelId = inModelID; string modelId = model.ModelId; //recognize form RecognizeCustomFormsOperation operation = await recognizerClient.StartRecognizeCustomFormsFromUriAsync(modelId, new Uri(formUrl)); Response <RecognizedFormCollection> operationResponse = await operation.WaitForCompletionAsync(); RecognizedFormCollection forms = operationResponse.Value; foreach (RecognizedForm form in forms) { returnString += $"Form of type: {form.FormType}{Environment.NewLine}"; foreach (FormField field in form.Fields.Values) { returnString += $"Field '{field.Name}: "; if (field.LabelData != null) { returnString += $" Label: '{field.LabelData.Text}"; } returnString += $" Value: '{field.ValueData.Text}"; returnString += $" Confidence: '{field.Confidence}{Environment.NewLine}"; } returnString += $"Table data:{Environment.NewLine}"; foreach (FormPage page in form.Pages) { for (int i = 0; i < page.Tables.Count; i++) { FormTable table = page.Tables[i]; //Console.WriteLine($"Table {i} has {table.RowCount} rows and {table.ColumnCount} columns."); foreach (FormTableCell cell in table.Cells) { returnString += $" Cell ({cell.RowIndex}, {cell.ColumnIndex}) contains {(cell.IsHeader ? "header" : "text")}: '{cell.Text}'{Environment.NewLine}"; } } } } // Delete the model on completion to clean environment. await trainingClient.DeleteModelAsync(model.ModelId); }
public async Task TrainModelWithForms() { string endpoint = TestEnvironment.Endpoint; string apiKey = TestEnvironment.ApiKey; #region Snippet:FormRecognizerSampleTrainModelWithForms // For this sample, you can use the training forms found in the `trainingFiles` folder. // Upload the forms to your storage container and then generate a container SAS URL. // For instructions on setting up forms for training in an Azure Storage Blob Container, see // https://docs.microsoft.com/azure/cognitive-services/form-recognizer/build-training-data-set#upload-your-training-data #if SNIPPET Uri trainingFileUri = < trainingFileUri >; #else Uri trainingFileUri = new Uri(TestEnvironment.BlobContainerSasUrlV2); #endif FormTrainingClient client = new FormTrainingClient(new Uri(endpoint), new AzureKeyCredential(apiKey)); TrainingOperation operation = await client.StartTrainingAsync(trainingFileUri, useTrainingLabels : false, "My Model"); Response <CustomFormModel> operationResponse = await operation.WaitForCompletionAsync(); CustomFormModel model = operationResponse.Value; Console.WriteLine($"Custom Model Info:"); Console.WriteLine($" Model Id: {model.ModelId}"); Console.WriteLine($" Model name: {model.ModelName}"); Console.WriteLine($" Model Status: {model.Status}"); Console.WriteLine($" Is composed model: {model.Properties.IsComposedModel}"); Console.WriteLine($" Training model started on: {model.TrainingStartedOn}"); Console.WriteLine($" Training model completed on: {model.TrainingCompletedOn}"); foreach (CustomFormSubmodel submodel in model.Submodels) { Console.WriteLine($"Submodel Form Type: {submodel.FormType}"); foreach (CustomFormModelField field in submodel.Fields.Values) { Console.Write($" FieldName: {field.Name}"); if (field.Label != null) { Console.Write($", FieldLabel: {field.Label}"); } Console.WriteLine(""); } } #endregion // Delete the model on completion to clean environment. await client.DeleteModelAsync(model.ModelId); }
public async Task RecognizeCustomFormsFromFile() { string endpoint = TestEnvironment.Endpoint; string apiKey = TestEnvironment.ApiKey; string trainingFileUrl = TestEnvironment.BlobContainerSasUrl; // Firstly, create a trained model we can use to recognize the custom form. Please note that // models can also be trained using a graphical user interface such as the Form Recognizer // Labeling Tool found here: // https://docs.microsoft.com/azure/cognitive-services/form-recognizer/quickstarts/label-tool FormTrainingClient trainingClient = new FormTrainingClient(new Uri(endpoint), new AzureKeyCredential(apiKey)); CustomFormModel model = await trainingClient.StartTrainingAsync(new Uri(trainingFileUrl), useTrainingLabels : false, new TrainingOptions() { ModelName = "My Model" }).WaitForCompletionAsync(); // Proceed with the custom form recognition. FormRecognizerClient client = new FormRecognizerClient(new Uri(endpoint), new AzureKeyCredential(apiKey)); string formFilePath = FormRecognizerTestEnvironment.CreatePath("Form_1.jpg"); string modelId = model.ModelId; using (FileStream stream = new FileStream(formFilePath, FileMode.Open)) { RecognizedFormCollection forms = await client.StartRecognizeCustomFormsAsync(modelId, stream).WaitForCompletionAsync(); foreach (RecognizedForm form in forms) { Console.WriteLine($"Form of type: {form.FormType}"); Console.WriteLine($"Form was analyzed with model with ID: {form.ModelId}"); foreach (FormField field in form.Fields.Values) { Console.WriteLine($"Field '{field.Name}: "); if (field.LabelData != null) { Console.WriteLine($" Label: '{field.LabelData.Text}"); } Console.WriteLine($" Value: '{field.ValueData.Text}"); Console.WriteLine($" Confidence: '{field.Confidence}"); } } } // Delete the model on completion to clean environment. await trainingClient.DeleteModelAsync(model.ModelId); }
// </snippet_getmodellist> // <snippet_deletemodel> // Delete a model private static async Task DeleteModel( FormTrainingClient formTrainingClient, string modelId) { try { Console.Write("Deleting model: {0}...", modelId.ToString()); await formTrainingClient.DeleteModelAsync(modelId); Console.WriteLine("done.\n"); } catch (RequestFailedException e) { Console.WriteLine("Delete model : " + e.Message); } Console.ReadLine(); }
public async Task TrainModelWithFormsAndLabels() { string endpoint = TestEnvironment.Endpoint; string apiKey = TestEnvironment.ApiKey; string trainingFileUrl = TestEnvironment.BlobContainerSasUrl; #region Snippet:FormRecognizerSampleTrainModelWithFormsAndLabels // For this sample, you can use the training forms found in the `trainingFiles` folder. // Upload the forms to your storage container and then generate a container SAS URL. // For instructions to set up forms for training in an Azure Storage Blob Container, please see: // https://docs.microsoft.com/azure/cognitive-services/form-recognizer/build-training-data-set#upload-your-training-data // For instructions to create a label file for your training forms, please see: // https://docs.microsoft.com/azure/cognitive-services/form-recognizer/quickstarts/label-tool FormTrainingClient client = new FormTrainingClient(new Uri(endpoint), new AzureKeyCredential(apiKey)); CustomFormModel model = await client.StartTrainingAsync(new Uri(trainingFileUrl), useTrainingLabels : true, new TrainingOptions() { ModelName = "My Model with labels" }).WaitForCompletionAsync(); Console.WriteLine($"Custom Model Info:"); Console.WriteLine($" Model Id: {model.ModelId}"); Console.WriteLine($" Model name: {model.ModelName}"); Console.WriteLine($" Model Status: {model.Status}"); Console.WriteLine($" Is composed model: {model.Properties.IsComposedModel}"); Console.WriteLine($" Training model started on: {model.TrainingStartedOn}"); Console.WriteLine($" Training model completed on: {model.TrainingCompletedOn}"); foreach (CustomFormSubmodel submodel in model.Submodels) { Console.WriteLine($"Submodel Form Type: {submodel.FormType}"); foreach (CustomFormModelField field in submodel.Fields.Values) { Console.Write($" FieldName: {field.Name}"); if (field.Accuracy != null) { Console.Write($", Accuracy: {field.Accuracy}"); } Console.WriteLine(""); } } #endregion // Delete the model on completion to clean environment. await client.DeleteModelAsync(model.ModelId); }
public async Task RecognizeCustomFormsFromFile() { string endpoint = TestEnvironment.Endpoint; string apiKey = TestEnvironment.ApiKey; string trainingFileUrl = TestEnvironment.BlobContainerSasUrl; // Firstly, create a trained model we can use to recognize the custom form. Please note that // models can also be trained using a graphical user interface such as the Form Recognizer // Labeling Tool found here: // https://docs.microsoft.com/azure/cognitive-services/form-recognizer/label-tool?tabs=v2-1 FormTrainingClient trainingClient = new FormTrainingClient(new Uri(endpoint), new AzureKeyCredential(apiKey)); CustomFormModel model = await trainingClient.StartTrainingAsync(new Uri(trainingFileUrl), useTrainingLabels : false, "My Model").WaitForCompletionAsync(); // Proceed with the custom form recognition. FormRecognizerClient client = new FormRecognizerClient(new Uri(endpoint), new AzureKeyCredential(apiKey)); #region Snippet:FormRecognizerRecognizeCustomFormsFromFile #if SNIPPET string modelId = "<modelId>"; string filePath = "<filePath>"; #else string filePath = FormRecognizerTestEnvironment.CreatePath("Form_1.jpg"); string modelId = model.ModelId; #endif using var stream = new FileStream(filePath, FileMode.Open); var options = new RecognizeCustomFormsOptions() { IncludeFieldElements = true }; RecognizeCustomFormsOperation operation = await client.StartRecognizeCustomFormsAsync(modelId, stream, options); Response <RecognizedFormCollection> operationResponse = await operation.WaitForCompletionAsync(); RecognizedFormCollection forms = operationResponse.Value; foreach (RecognizedForm form in forms) { Console.WriteLine($"Form of type: {form.FormType}"); Console.WriteLine($"Form was analyzed with model with ID: {form.ModelId}"); foreach (FormField field in form.Fields.Values) { Console.WriteLine($"Field '{field.Name}': "); if (field.LabelData != null) { Console.WriteLine($" Label: '{field.LabelData.Text}'"); } Console.WriteLine($" Value: '{field.ValueData.Text}'"); Console.WriteLine($" Confidence: '{field.Confidence}'"); } // Iterate over tables, lines, and selection marks on each page foreach (var page in form.Pages) { for (int i = 0; i < page.Tables.Count; i++) { Console.WriteLine($"Table {i+1} on page {page.Tables[i].PageNumber}"); foreach (var cell in page.Tables[i].Cells) { Console.WriteLine($" Cell[{cell.RowIndex}][{cell.ColumnIndex}] has text '{cell.Text}' with confidence {cell.Confidence}"); } } Console.WriteLine($"Lines found on page {page.PageNumber}"); foreach (var line in page.Lines) { Console.WriteLine($" Line {line.Text}"); } if (page.SelectionMarks.Count != 0) { Console.WriteLine($"Selection marks found on page {page.PageNumber}"); foreach (var selectionMark in page.SelectionMarks) { Console.WriteLine($" Selection mark is '{selectionMark.State}' with confidence {selectionMark.Confidence}"); } } } } #endregion // Delete the model on completion to clean environment. await trainingClient.DeleteModelAsync(model.ModelId); }
public override async Task GlobalCleanupAsync() { await _trainingClient.DeleteModelAsync(_modelId); await base.GlobalCleanupAsync(); }
public async Task CreateComposedModel() { string endpoint = TestEnvironment.Endpoint; string apiKey = TestEnvironment.ApiKey; string trainingFileUrl = TestEnvironment.BlobContainerSasUrl; FormTrainingClient client = new FormTrainingClient(new Uri(endpoint), new AzureKeyCredential(apiKey)); string purchaseOrderOfficeSuppliesUrl = trainingFileUrl; string purchaseOrderOfficeEquipmentUrl = trainingFileUrl; string purchaseOrderFurnitureUrl = trainingFileUrl; string purchaseOrderCleaningSuppliesUrl = trainingFileUrl; #region Snippet:FormRecognizerSampleTrainVariousModels // For this sample, you can use the training forms found in the `trainingFiles` folder. // Upload the forms to your storage container and then generate a container SAS URL. // For instructions on setting up forms for training in an Azure Storage Blob Container, see // https://docs.microsoft.com/azure/cognitive-services/form-recognizer/build-training-data-set#upload-your-training-data //@@ string purchaseOrderOfficeSuppliesUrl = "<purchaseOrderOfficeSupplies>"; //@@ string purchaseOrderOfficeEquipmentUrl = "<purchaseOrderOfficeEquipment>"; //@@ string purchaseOrderFurnitureUrl = "<purchaseOrderFurniture>"; //@@ string purchaseOrderCleaningSuppliesUrl = "<purchaseOrderCleaningSupplies>"; CustomFormModel purchaseOrderOfficeSuppliesModel = (await client.StartTrainingAsync(new Uri(purchaseOrderOfficeSuppliesUrl), useTrainingLabels: true, "Purchase order - Office supplies").WaitForCompletionAsync()).Value; CustomFormModel purchaseOrderOfficeEquipmentModel = (await client.StartTrainingAsync(new Uri(purchaseOrderOfficeEquipmentUrl), useTrainingLabels: true, "Purchase order - Office Equipment").WaitForCompletionAsync()).Value; CustomFormModel purchaseOrderFurnitureModel = (await client.StartTrainingAsync(new Uri(purchaseOrderFurnitureUrl), useTrainingLabels: true, "Purchase order - Furniture").WaitForCompletionAsync()).Value; CustomFormModel purchaseOrderCleaningSuppliesModel = (await client.StartTrainingAsync(new Uri(purchaseOrderCleaningSuppliesUrl), useTrainingLabels: true, "Purchase order - Cleaning Supplies").WaitForCompletionAsync()).Value; #endregion #region Snippet:FormRecognizerSampleCreateComposedModel List <string> modelIds = new List <string>() { purchaseOrderOfficeSuppliesModel.ModelId, purchaseOrderOfficeEquipmentModel.ModelId, purchaseOrderFurnitureModel.ModelId, purchaseOrderCleaningSuppliesModel.ModelId }; CustomFormModel purchaseOrderModel = (await client.StartCreateComposedModelAsync(modelIds, "Composed Purchase order").WaitForCompletionAsync()).Value; Console.WriteLine($"Purchase Order Model Info:"); Console.WriteLine($" Is composed model: {purchaseOrderModel.Properties.IsComposedModel}"); Console.WriteLine($" Model Id: {purchaseOrderModel.ModelId}"); Console.WriteLine($" Model name: {purchaseOrderModel.ModelName}"); Console.WriteLine($" Model Status: {purchaseOrderModel.Status}"); Console.WriteLine($" Create model started on: {purchaseOrderModel.TrainingStartedOn}"); Console.WriteLine($" Create model completed on: {purchaseOrderModel.TrainingCompletedOn}"); #endregion #region Snippet:FormRecognizerSampleSubmodelsInComposedModel Dictionary <string, List <TrainingDocumentInfo> > trainingDocsPerModel = purchaseOrderModel.TrainingDocuments.GroupBy(doc => doc.ModelId).ToDictionary(g => g.Key, g => g.ToList()); Console.WriteLine($"The purchase order model is based on {purchaseOrderModel.Submodels.Count} model{(purchaseOrderModel.Submodels.Count > 1 ? "s" : "")}."); foreach (CustomFormSubmodel model in purchaseOrderModel.Submodels) { Console.WriteLine($" Model Id: {model.ModelId}"); Console.WriteLine(" The documents used to trained the model are: "); foreach (var doc in trainingDocsPerModel[model.ModelId]) { Console.WriteLine($" {doc.Name}"); } } #endregion string purchaseOrderFilePath = FormRecognizerTestEnvironment.CreatePath("Form_1.jpg"); #region Snippet:FormRecognizerSampleRecognizeCustomFormWithComposedModel //@@ string purchaseOrderFilePath = "<purchaseOrderFilePath>"; FormRecognizerClient formRecognizerClient = client.GetFormRecognizerClient(); RecognizedFormCollection forms; using (FileStream stream = new FileStream(purchaseOrderFilePath, FileMode.Open)) { forms = await formRecognizerClient.StartRecognizeCustomFormsAsync(purchaseOrderModel.ModelId, stream).WaitForCompletionAsync(); // Find labeled field. foreach (RecognizedForm form in forms) { // Setting an arbitrary confidence level if (form.FormTypeConfidence.Value > 0.9) { if (form.Fields.TryGetValue("Total", out FormField field)) { Console.WriteLine($"Total value in the form `{form.FormType}` is `{field.ValueData.Text}`"); } } else { Console.WriteLine("Unable to recognize form."); } } } #endregion // Delete the models on completion to clean environment. await client.DeleteModelAsync(purchaseOrderOfficeSuppliesModel.ModelId).ConfigureAwait(false); await client.DeleteModelAsync(purchaseOrderOfficeEquipmentModel.ModelId).ConfigureAwait(false); await client.DeleteModelAsync(purchaseOrderFurnitureModel.ModelId).ConfigureAwait(false); await client.DeleteModelAsync(purchaseOrderCleaningSuppliesModel.ModelId).ConfigureAwait(false); await client.DeleteModelAsync(purchaseOrderModel.ModelId).ConfigureAwait(false); }
public override async Task CleanupAsync() { await _trainingClient.DeleteModelAsync(_modelId); }
private async void DeleteModel(string modelId) { FormTrainingClient trainingClient = InstrumentClient(new FormTrainingClient(_endpoint, _credential)); await trainingClient.DeleteModelAsync(modelId).ConfigureAwait(false); }
/// <summary> /// Deletes the model this instance is associated with. /// </summary> public async ValueTask DisposeAsync() => await _trainingClient.DeleteModelAsync(ModelId);
//[HttpPost] //[Route("api/RemoveModel")] //public ActionResult RemoveModel([FromBody] FormDelete newForm) //{ // var recognizerClient = AuthenticateClient(); // var deleteModel = DeleteModel(recognizerClient, newForm.modelId); // Task.WaitAll(deleteModel); // return Ok($"Model ID#: {newForm.modelId} has been removed."); //} #endregion #region Delete Form private static async Task DeleteModel(FormRecognizerClient recognizerClient, string modelID) { FormTrainingClient trainingClient = new FormTrainingClient(new Uri(endpoint), new AzureKeyCredential(apiKey)); await trainingClient.DeleteModelAsync(modelID); }
/// <summary> /// Deletes the model with the specified model ID. /// </summary> /// <param name="modelId">The ID of the model to delete.</param> private async void DeleteModel(string modelId) { FormTrainingClient client = CreateInstrumentedFormTrainingClient(); await client.DeleteModelAsync(modelId); }