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.
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
Asked: 2023-07-06 00:12:18 +0000
Seen: 11 times
Last updated: Jul 06 '23
How can I prevent the modification of another object's property through reference?
What is the method for creating a subcollection in Firebase Firestore?
How can a Web Reference be incorporated into .NET Core?
How can I transfer a formula from one worksheet to another by using a cell reference?
What is the outcome of dereferencing Box<T> - does it provide a value or a reference?
What is a reference for UIElement?
What is the method to calculate the total of all the numbers in this column?
How can you insert new elements into the beginning of the parent using the DOM?