Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.