【问题标题】:Stuck: How to link/connect two Azure Logic Apps together?卡住:如何将两个 Azure 逻辑应用程序链接/连接在一起?
【发布时间】:2020-04-23 04:24:30
【问题描述】:

我在尝试将两个 Azure 逻辑应用连接/链接在一起时遇到了一些问题。

这是我的场景以及我尝试使用逻辑应用程序的方式。

我创建了第一个逻辑应用:允许用户将 .mp4 媒体文件上传到 OneDrive 上的文件夹中,逻辑应用检查该 OneDrive 文件夹上是否有新文件。如果有新文件,它将触发逻辑应用并将视频索引到https://www.videoindexer.ai/

第二个 - 逻辑应用程序:视频被索引到 https://www.videoindexer.ai/ 后,我希望用户从我创建的自定义网页中选择语言,用于字幕翻译 (here is the custom web page)。一旦用户选择了他们点击“提交”的语言,这会将数据(语言)发送到我的第二个逻辑应用 URL 端点,并触发我的第二个逻辑应用并根据用户的选择获取标题语言。最后,它会将这些字幕文件输出到 OneDrive 文件夹。

这是我创建这两个逻辑应用程序的方式:

第一个逻辑应用程序:

第二个逻辑APP:

HTML:

<form id="language-form">
<h3>Please select the languages(s) for translating captions: </h3>
  <ul>
    <li><label><input type="checkbox" name="language" value="en-US"> English</label></li>
    <li><label><input type="checkbox" name="language" value="es-ES"> Spanish</label></li>
    <li><label><input type="checkbox" name="language" value="ko-KR"> Korean</label></li>
    <li><label><input type="checkbox" name="language" value="th-TH"> Thai</label></li>
    <li><label><input type="checkbox" name="language" value="ja-JP"> Japanese</label></li>
  </ul>
  <button type="submit">Submit</button>
</form>

JavaScript:

function fetchForLanguages(languages) {
  console.info('starting fetch for', languages)
  return fetch("https://prod-00.westus2.logic.azure.com:443/workflows/xxxxxxxxxxxxxxxxx", { // this is my azure  provided endpoint
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      languages: languages
    })
  }).then(response => {
    if (!response.ok) {
      throw new Error(`Network response was not ok: ${response.status} ${response.statusText}`);
    }
    return response.json()
  })
}


function handleSubmit(event) {
  event.preventDefault()
  const data = new FormData(event.currentTarget)
  const languages = data.getAll('language')
  console.info('languages selected:', languages)
  fetchForLanguages(languages)
    .then((result) => console.log('got result:', result))
}

let form = document.getElementById('language-form')
form.addEventListener('submit', handleSubmit)

【问题讨论】:

标签: azure azure-logic-apps azure-cognitive-services


【解决方案1】:

这里的工作流程与您的解释非常相似:

[https://azure.microsoft.com/en-us/blog/logic-apps-flow-connectors-will-make-automating-video-indexer-simpler-than-ever/][1]

这是在发送电子邮件之前检查文件是否准备好的python函数:

import requests

loc = '' # location 
acc_id = '' # account id
vi_subscription_key = '' # primary key

def get_access_token(loc, acc_id):

    headers = {'Ocp-Apim-Subscription-Key': vi_subscription_key}
    params = {'allowEdit': 'true'}

    access_token_req = requests.get(
        f'https://api.videoindexer.ai/auth/{loc}/Accounts/{acc_id}/AccessToken',
        params=params,
        headers=headers)

    access_token = access_token_req.text[1:-1]

    return access_token


def is_video_proccessed(loc, acc_id, access_token, video_id, video_language='English'):        

    params = {'accessToken': access_token,
            'language': video_language }


    get_video_info_req = requests.get(
        f'https://api.videoindexer.ai/{loc}/Accounts/{acc_id}/Videos/{video_id}/Index',
        params=params)

    response = get_video_info_req.json()       

    if (response['state'] != "Uploaded") and (response['state'] != 'Processing'):
        print(f'Video {video_id} finished processing')
        return True

希望对您有所帮助。

【讨论】:

  • 我也在学习它。但我专注于使用python。如果您可以集成用于检查文件已完成处理的统计信息的 Azure 函数应用程序,则您可以发送电子邮件。我会将函数添加到答案中。
  • 在(发送邮件)步骤之前,添加Function App,然后添加(控制步骤)检查功能应用是否返回True,然后发送邮件。
猜你喜欢
  • 1970-01-01
  • 2023-01-19
  • 1970-01-01
  • 2020-09-29
  • 2020-05-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-10
  • 2020-03-20
相关资源
最近更新 更多