![](/img/trans.png)
[英]How to manually invoke a Timer Trigger Azure function on Azure Portal?
[英]Calling Azure Function ( Queue Trigger) Doesnt work , but it does when i send i message from azure portal
我正在處理一個具有以下詳細信息的個人項目: net core 6 with c# web app and az functions 。 我有一個顯示消息並發送 email 的隊列觸發器(Az 函數),我想將其稱為來自 Azure Function 的隊列。我使用正確的連接字符串和隊列名稱,因為如果我從 azure 門戶發送消息,我看到了隊列消息,我能夠在本地調試它並且我還收到了 Email。
但是當我從我的代碼(另一個 Az 函數)進行調用時,我看到來自門戶的隊列消息,但我無法在本地調試它並且我沒有收到 email。
很明顯,它可以在門戶網站上運行,但不能在本地(或產品)運行,我的代碼有問題。 我正在使用此代碼從我的代碼中進行調用:
try
{
string conectionstring = "Myconnection";
QueueClient queue = new QueueClient(conectionstring, "myQueueName");
var rspqueue = await queue.SendMessageAsync("MyMessage");
}
catch (Exception ex)
{
throw;
}
這顯示 201 消息,正如我所說,我看到來自 azure 門戶的消息。 SendMessageAsync 不應該調用我的隊列觸發器(Az 函數)嗎? 或者我弄錯了?
問候
我試圖從另一個 Az Function 調用隊列觸發器(Az 函數)。我希望知道該怎么做
好吧,您沒有調用隊列觸發器,但顧名思義,您正在向隊列中添加消息並且隊列觸發器被觸發。
這里我有一個 http 觸發器,它將消息添加到隊列中。
[FunctionName("Function1")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
string connectionString = "<Connection String>";
QueueClient queue = new QueueClient(connectionString, "testr");
string message = Convert.ToBase64String(Encoding.UTF8.GetBytes("Hello World "));
queue.SendMessage(message);
return new OkObjectResult("responseMessage");
}
[FunctionName("Function1")]
public void Run([QueueTrigger("testr", Connection = "test")]string myQueueItem, ILogger log)
{
log.LogInformation($"C# Queue trigger function processed: {myQueueItem}");
}
隊列觸發器 output:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.