Resize Images using Azure Functions

Written by ppolyzos

Software engineer based in Athens, Greece

9 Comments

    1. ppolyzos

      This is a bit tricky as by default the output Stream is set to application/octet-stream and CloudBlockBlob can’t be used for output binding. However, you can declare CloudBlockBlob as “inout” in function.json file and it will work properly.

      function.json

      And the function code to achieve custom ContentType is the following:

  1. Tushar

    2017-06-02T13:45:21 Welcome, you are now connected to log-streaming service.
    2017-06-02T13:45:23.809 Function compilation error
    2017-06-02T13:45:23.809 (1,7): error CS0246: The type or namespace name ‘ImageResizer’ could not be found (are you missing a using directive or an assembly reference?)
    2017-06-02T13:45:23.809 (2,7): error CS0246: The type or namespace name ‘ImageResizer’ could not be found (are you missing a using directive or an assembly reference?)
    2017-06-02T13:45:23.809 (8,28): error CS0246: The type or namespace name ‘Instructions’ could not be found (are you missing a using directive or an assembly reference?)
    2017-06-02T13:45:23.809 (11,16): error CS0103: The name ‘FitMode’ does not exist in the current context
    2017-06-02T13:45:23.809 (12,17): error CS0103: The name ‘ScaleMode’ does not exist in the current context
    2017-06-02T13:45:23.809 (14,5): error CS0103: The name ‘ImageBuilder’ does not exist in the current context
    2017-06-02T13:45:23.809 (14,36): error CS0246: The type or namespace name ‘ImageJob’ could not be found (are you missing a using directive or an assembly reference?)
    2017-06-02T13:45:31.387 Script for function ‘ImageResizer’ changed. Reloading.
    2017-06-02T13:45:31.718 (2,7): error CS0246: The type or namespace name ‘ImageResizer’ could not be found (are you missing a using directive or an assembly reference?)
    2017-06-02T13:45:31.718 (3,7): error CS0246: The type or namespace name ‘ImageResizer’ could not be found (are you missing a using directive or an assembly reference?)
    2017-06-02T13:45:31.718 (9,28): error CS0246: The type or namespace name ‘Instructions’ could not be found (are you missing a using directive or an assembly reference?)
    2017-06-02T13:45:31.718 (12,16): error CS0103: The name ‘FitMode’ does not exist in the current context
    2017-06-02T13:45:31.718 (13,17): error CS0103: The name ‘ScaleMode’ does not exist in the current context
    2017-06-02T13:45:31.718 (15,5): error CS0103: The name ‘ImageBuilder’ does not exist in the current context
    2017-06-02T13:45:31.718 (15,36): error CS0246: The type or namespace name ‘ImageJob’ could not be found (are you missing a using directive or an assembly reference?)
    2017-06-02T13:45:31.718 warning AF004: Missing binding argument named ‘inputBlob’. Mismatched binding argument names may lead to function indexing errors.
    2017-06-02T13:45:31.718 Compilation failed.

    I am always getting this error I tried everything

  2. Dani Pazos

    Hi,

    Thank you for your article. I was wondering if there is a way to resize the images stored in every container of a storage and not a specific one. In our storage we create a new container for every bill we handle and then add pictures to that container related to the bill. How could I create thumbnails to those containers using Azure functions?

    1. ppolyzos

      I don’t think this is possible at the moment. Usually you need to pass the container to monitor in the path parameter.

      However you could follow another approach where you have one container for input and one container for output, and then create a folder inside each container based on your customer id or name, or use your customer’s id before input/output blob name.

      Even in Azure WebJobs this feature is not yet possible. There is an open issue here, so you could vote for it.

      1. Dani Pazos

        Thank you for your reply. I was looking around and found that maybe using Azure Event Grid could be a good approach although it is still a preview version.

  3. manjunath

    hello ppolyzos,

    Great artical by the way, saved almost day work 🙂

    is there any way to create thumbnail out of Uploaded video using azure function?

Leave a Comment

Your email address will not be published. Required fields are marked *