/// <summary> /// Gets the URL on which the workflow with trigger can be run by searching the workflow for configured triggers. /// </summary> /// <exception cref="LogicAppTriggerNotFoundException">When no trigger can be found on the logic app.</exception> public async Task<LogicAppTriggerUrl> GetTriggerUrlAsync() { string triggerName = await GetTriggerNameAsync(); LogicAppTriggerUrl triggerUrl = await GetTriggerUrlByNameAsync(triggerName); return triggerUrl; }
public async Task GetLogicAppTriggerUrl_ByName_Success() { // Arrange using (var logicApp = await LogicAppClient.CreateAsync(ResourceGroup, LogicAppName, Authentication)) { // Act LogicAppTriggerUrl logicAppTriggerUrl = await logicApp.GetTriggerUrlByNameAsync(triggerName : "manual"); // Assert Assert.NotNull(logicAppTriggerUrl.Url); Assert.Equal("POST", logicAppTriggerUrl.Method); } }
/// <summary> /// Run logic app on the current trigger URL, posting the given <paramref name="headers"/>. /// </summary> /// <param name="headers">The headers to send with the trigger URL of the current logic app.</param> public async Task TriggerAsync(IDictionary <string, string> headers) { Guard.NotNull(headers, nameof(headers)); Guard.NotAny(headers, nameof(headers)); LogicAppTriggerUrl triggerUrl = await GetTriggerUrlAsync(); _logger.LogTrace("Trigger the workflow of logic app '{LogicAppName}' in resource group '{ResourceGroup}'", _logicAppName, _resourceGroup); using (var request = new HttpRequestMessage(HttpMethod.Post, triggerUrl.Url)) { foreach (KeyValuePair <string, string> header in headers) { request.Headers.Add(header.Key, header.Value); } using (HttpResponseMessage response = await HttpClient.SendAsync(request)) { } } }