简体   繁体   中英

How to trigger Azure function with flutter

I created an azure function in c # and set up an HTTP trigger. I'm interested in how to call this function from the flutter application. I don't need to transfer any special data because everything is already in the link I use to call the function.I've created a simplified view of the function to demonstrate what I want.

https://functionapp220220124204147.azurewebsites.net/api/Quercus?status=Off

When it calls this function all it needs to do is change the value of the variable from on to off

I know this is not the correct way to make a function and I should not have such variables, but this is just a simplified version

Here is a workaround given by Vikash Kumar in the Medium article regarding How to call Azure Functions API through Flutter App Code:

  • Created Wordle Website which has a list of legit words and allows you to input a word only from that list where we validate if an input word is a legit English word.

  • First, he created the Azure Cosmos DB > container in it > added a few dates, word pairs like:在此处输入图像描述

  • Created the Azure Functions which has input binding with the Cosmos DB and gets a list of stored words on every request.

  • This functionality is broken into 3 segments:

  • Validate the input word (not null, same length, convert to uppercase both)

  • Check if both words are the same

  • Status of each letter in the input word.

The deployed function app API will be in this format: https://wordle-api.azurewebsites.net/api/CheckWord?word=

Also created the flutter in the composition of the word_field component which creates an input widget that accepts a 5 letter word in 5 boxes (1 each) which is similar to the OTP field.

  • And the home component builds a scaffold and puts together a page to accept 6 attempts for words.
  • The _checkWord handler calls the wordle-api , gets the color code, and updates the components accordingly.
  • Calling the Function API in the above handler and writing the code about response status and the user-defined message to the response.

var uri = Uri.https('wordle-api.azurewebsites.net', '/api/CheckWord', params);

For Complete Code, Please refer this article .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM