Ask Your Question
2

How can the client reference "Blob AzureStorage" be converted to "FormRecognizer" in C# if there is an error stating that "System.Uri" cannot be converted to "string"?

asked 2023-07-06 00:12:18 +0000

scrum gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-07-06 00:17:01 +0000

ladyg gravatar image

To convert the "Blob AzureStorage" reference to "FormRecognizer" in C# when there is an error stating that "System.Uri" cannot be converted to "string", you can use the AbsoluteUri property of the URI to get the string representation of the URI.

Here is an example:

// Create a BlobServiceClient object
BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);

// Get a BlobClient object for the blob
BlobClient blobClient = blobServiceClient.GetBlobClient(blobUrl);

// Convert the URI to a string
string blobUri = blobClient.Uri.AbsoluteUri;

// Use the blob URI with the FormRecognizer client
FormRecognizerClient formRecognizerClient = new FormRecognizerClient(new Uri(formRecognizerEndpoint), new Azure.AzureKeyCredential(formRecognizerApiKey));
RecognizedFormCollection forms = await formRecognizerClient.StartRecognizeContentFromUriAsync(new Uri(blobUri)).WaitForCompletionAsync();

In this example, we first create a BlobServiceClient object with the connectionString, and then use it to get a BlobClient object for the blob with blobUrl.

Then, we convert the blobClient.Uri to a string using its AbsoluteUri property, and use this string with the FormRecognizerClient.

Note that the formRecognizerEndpoint and formRecognizerApiKey should be replaced with the actual values for your Form Recognizer service.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-07-06 00:12:18 +0000

Seen: 11 times

Last updated: Jul 06 '23