0

参考我的旧线程 如何实现我的 Azure 函数以在 PowerApps 中使用它

我仍在努力将我的功能实现到 powerapps 我真的不知道接下来我必须做什么。该功能本身已经在工作。但是,如果我想通过 url 执行它,它就不起作用(401 http 错误)

我的网址:https ://XXX.azurewebsites.net/api/XXX/?blobname1=image1.png&blobname2=image2.png

    [FunctionName("ConvertMe")]
public async static Task RunASync([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
  [Blob("test", FileAccess.ReadWrite)] CloudBlobContainer blobContainer,
     [Blob("test/out3.png", FileAccess.ReadWrite)] CloudBlockBlob outputBlob, ILogger log)

{

    try
    {
        ConvertMe Converter = new ConvertMe();
        MemoryStream stream1 = new MemoryStream();
        MemoryStream stream2 = new MemoryStream();
        log.LogInformation($"Containername: {blobContainer.Name} \nPublic Access: {blobContainer.Properties.PublicAccess} \nOriginal Path: {blobContainer.Uri.OriginalString}");
        string name1 = req.Query["blobname1"];
        string name2 = req.Query["blobname2"];



        CloudBlob blob1 = blobContainer.GetBlobReference(name1);
        CloudBlob blob2 = blobContainer.GetBlobReference(name2);

        await blob1?.DownloadToStreamAsync(stream1);
        stream1.Position = 0;
        await blob2?.DownloadToStreamAsync(stream2);
        stream2.Position = 0;

        MagickImage _Main = new MagickImage(stream1, MagickFormat.Png);
        MagickImage _Overlay = new MagickImage(stream2, MagickFormat.Png);

        using (MemoryStream memory = new MemoryStream())
        {
            Converter.ComebineBitmap(_Main, _Overlay).Write(memory, MagickFormat.Png);
            memory.Position = 0;
            outputBlob.Properties.ContentType = "image/png";

            await outputBlob?.UploadFromStreamAsync(memory);
        }
    }
    catch (System.Exception e)
    {

        log.LogError(e.Message);

    }
    finally
    {
        log.LogInformation("Wuhu ich bin durch");
    }



}

Power Apps 示例

这就是我想在 PowerApps OnClick 事件中组合图像的方式

"AzureFunction.ConvertMe(Input1:PictureBox.Image, Input2:PenInput; Output:CDS_Image.OUTputfield)"

所以我认为我真的不需要 blobobjects 作为输入还是我误解了什么?

我正在尝试遵循本指南,但我真的不知道如何为我的示例构建/设置正确的 swagger.json

4

0 回答 0