0

With Reference to my old Thread How to implement My Azure function for using it in PowerApps

Im still struggling with implementing my function to powerapps I dont really know what I have to do next. The function itself is already working. But If I want to execute it over an url it does not work (401 http error)

MY Url: 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 Example

This is how I want to compose the images in PowerApps OnClick Event

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

So I think I dont really need blobobjects as Inputs or am I misunderstanding something ?

Im trying to follow this guide, but I dont really know how to build/setup the correct swagger.json for my example

wambo
  • 67
  • 1
  • 10
  • 1
    Hey @wambo, I'm wondering if the answers your other questions last week actually answer this one? What is the the specific question you are asking here that you didn't ask here:https://stackoverflow.com/questions/60169520/how-to-implement-my-azure-function-for-using-it-in-powerapps or here: https://stackoverflow.com/questions/60229963/how-to-setup-swagger-for-powerapps-correctly – Jon Feb 17 '20 at 14:37
  • Im still struggling and finally found out the problem that cause all this confusing questions :P So this thread is deprecated because Im using the way in this thread https://stackoverflow.com/questions/60229963/how-to-setup-swagger-for-powerapps-correctly – wambo Feb 17 '20 at 15:44

0 Answers0