gpt4 book ai didi

c# - Microsoft 计算机视觉 API 返回 404 未找到资源

转载 作者:行者123 更新时间:2023-12-03 02:43:12 27 4
gpt4 key购买 nike

我尝试调用 Azure 的 Computer Vision API使用下面的 C# 代码但得到以下响应:

{"code":"404","message":"Resource not found"}

对于完成这项工作有什么建议吗?

using System;
using System.IO;
using System.Threading.Tasks;
using AzureFunctions.Extensions.CognitiveServices.Bindings.Vision.Analysis;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
using Microsoft.WindowsAzure.Storage.Table;

namespace myCognitiveFunction
{
public static class myCognitiveFunction
{
[FunctionName("myCognitiveFunction")]
public static async Task RunAsync(

[BlobTrigger("images/{name}", Connection = "storageAccount")]Stream myBlob,
[VisionAnalysis(VisionKey = "Key", VisionUrl = "Url")]VisionAnalysisClient visionClient,
[Table("VisionAnalysis", Connection = "storageAccount")]IAsyncCollector<VisionResult> results,
string name, ILogger log)
{
var request = new VisionAnalysisRequest(myBlob);
var result = await visionClient.AnalyzeAsync(request);
var visionResult = new VisionResult(Guid.NewGuid().ToString(), "VisionAnalysis") { ResultJson = result.ToString() };

await results.AddAsync(visionResult);
log.LogInformation($"Results: {result.ToString()}");
}
}
public class VisionResult : TableEntity
{

public VisionResult(string id, string partitionKey)
{
this.RowKey = id;
this.PartitionKey = partitionKey;
}

public string ResultJson { get; set; }

}
}

网址:https://mycognitive1000.cognitiveservices.azure.com/

最佳答案

首先,欢迎来到SO!看来您已经从文档中复制了代码,而没有替换占位符,即 storageAccountKeyUrl...,这是服务工作。例如,在您的情况下,在您的问题下发布的 URL 应位于 VisionUrl 属性中,如下所示:

[VisionAnalysis(VisionKey = "YOUR_KEY", VisionUrl = "mycognitive1000.cognitiveservices.azure.com")]

存储帐户是 Azure Blob Storage连接字符串。至于Vision Key和Url,您可以在Computer Vision API上找到很好的教程和文档。在官方文档中。本教程还解释了如何将这些参数写入单独的配置文件中作为最佳实践。

关于c# - Microsoft 计算机视觉 API 返回 404 未找到资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60065532/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com