我正在使用 ServiceBus.Extensions 5.7.0 并且有一個由 HttpTrigger 觸發的 Azure 函式。我想通過此函式向我的 Azure 訊息總線上的主題發送訊息。如何才能做到這一點?我的函式必須回傳 HttpResponseData 作為對 http 請求的回應。我也不能使用 ServiceBusOutput 屬性,因為它不允許用于我函式中的引數。
uj5u.com熱心網友回復:
在 Isolated Worker SDK 中,此場景稱為多輸出場景。您需要回傳一個帶有屬性的 POCO,其中一個屬性將映射到 HTTP 回應,另一個映射到 Azure 服務總線物體。
public class MyOutputType
{
public HttpResponseData HttpResponse { get; set; } // HTTP response [ServiceBusOutput(queueOrTopicName: "dest", Connection = "AzureServiceBus")]
public string Message { get; set; } // message payload
}
在你的函式中,你會回傳一個MyOutputType.
[Function("MultiOutput")]
public static MyOutputType Run([HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequestData req,
FunctionContext context)
{
var response = req.CreateResponse(HttpStatusCode.OK);
response.WriteString("Success!");
var myQueueOutput = "Payload for ASB";
return new MyOutputType
{
Message = myQueueOutput,
HttpResponse = response
};
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/533839.html
上一篇:Azure資料工廠復制檔案
下一篇:嘗試從本地主機和應用程式域訪問https://login.microsoftonline.com/common/oauth2/v2.0/token'到“acquireTokenOnBehal
