如何实现My Azure功能以在PowerApps中使用它 [英] How to implement My Azure function for using it in PowerApps
问题描述
我目前正在尝试编写一个函数,以将天蓝色存储中的两个图像组合为一个图像. 我不知道如何设置我的函数类,这样我就可以在具有2个选定图像的powerapps中触发该函数.
Im currently trying to write a function to combine two images from azure storage to one image. I dont know how to setup my function class so that I can trigger the function in powerapps with 2 selected images.
这是我的课程
public static class Function1
{
[Obsolete] // switch TraceWrite to Ilogger
[FunctionName("Function1")]
public static void Run(string background, string overlay, CloudBlockBlob outputBlob, TraceWriter log)
{
log.Info($"Function triggered with blob\n Background: {background} \n Overlay: {overlay}");
ConvertMe Converter = new ConvertMe(System.Drawing.Color.Black); // My ImageEdit Class I have written
Bitmap _Main = new Bitmap(background);
Bitmap Overlay = Converter.MakeTransparent(overlay);
using (MemoryStream memory = new MemoryStream())
{
Converter.ComebineBitmap(_Main, Overlay).Save(memory, ImageFormat.Jpeg);
memory.Position = 0;
outputBlob.Properties.ContentType = "image/jpeg";
outputBlob.UploadFromStreamAsync(memory);
}
}
}
推荐答案
首先,假设您已经知道不能直接调用函数,尤其是使用blob触发器函数.
Firstly, suppose you already know you could not directly call your function, especially you are using blob trigger function.
然后是有关如何在Power应用程序中使用功能的信息.有关于此的博客:在PowerApps中使用Azure函数.您需要http触发函数,并使用Swagger定义REST签名,然后在强力应用程序中使用自定义API.
Then is about how to use function in power apps. There is blog about this: Using Azure Functions in PowerApps. You need the http trigger function and define the REST signature using Swagger then use the custom API in power apps.
最后一件事是关于如何在http触发函数中获得两个blob.从Blob绑定文档中,您可以获取输入用法,您会发现c#或c#脚本函数均支持CloudBlockBlob
绑定.
The last thing is about how to get two blob in the http trigger function. From the blob binding doc you could get the Input-usage, you could find the c# or c# script function both support CloudBlockBlob
binding.
下面是从具有Http触发功能的两个txt blob中读取的示例,您可以添加输出绑定以存储输出图像.
The below is a sample read from two txt blob with http trigger function, you could add an output binding to storage the output image.
public static class Function1
{
[FunctionName("Function1")]
public static async Task RunAsync(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
[Blob("test/test.txt",FileAccess.ReadWrite)]CloudBlockBlob blob1,
[Blob("test/out.txt", FileAccess.ReadWrite)]CloudBlockBlob blob2,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string test = await blob1.DownloadTextAsync();
string outtxt = await blob2.DownloadTextAsync();
log.LogInformation("test value: " + test);
log.LogInformation("outtxt value: " + outtxt);
}
}
然后关注该博客,假设它可以解决问题,希望对您有所帮助,如果您还有其他问题,请随时告诉我.
Then follow the blog, suppose this could work, hope this could help you, if you still have other problem, please feel free to let me know.
这篇关于如何实现My Azure功能以在PowerApps中使用它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!