title: How do I fix this 502 Error on my Azure Function?
body: <p>My Azure Function does not work anymore.<br>
  I didn't change anything on my code or settings and it suddenly stopped working after one week.</p>
  
  <pre><code>
  &lt;title&gt;502 - Web server received an invalid response while acting as a gateway or proxy server.&lt;/title&gt;
  
  
        &lt;h1&gt;Server Error&lt;/h1&gt;
  
      &lt;div id="content"&gt;
        &lt;div class="content-container"&gt;
          &lt;fieldset&gt;
            &lt;h2&gt;502 - Web server received an invalid response while acting as a gateway or proxy server.&lt;/h2&gt;
            &lt;h3&gt;There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.
  
  
  </code></pre>
  
  <pre><code> log.LogInformation($"Received a Request");
              ConvertMe Converter = new ConvertMe();
              var content = await new StreamReader(req.Body).ReadToEndAsync();
              if (content != null)
              {
                  Imagebody imagebody = JsonConvert.DeserializeObject&lt;Imagebody&gt;(content);
                  MagickImage _Main = new MagickImage(Convert.FromBase64String(imagebody.image1), MagickFormat.Png);
                  MagickImage _Overlay = new MagickImage(Convert.FromBase64String(imagebody.image2), MagickFormat.Png);
  
                  using (MemoryStream memory = new MemoryStream())
                  {
                      Converter.ComebineBitmap(_Main, _Overlay).Write(memory, MagickFormat.Png);
                      memory.Position = 0;
                      log.LogInformation($"Result: {Convert.ToBase64String(memory?.ToArray())}");
                      return @"data:image/png;base64," + Convert.ToBase64String(memory?.ToArray());
                  }
              }
  </code></pre>
  
  <p>This is my code which is already working (live).
  So I really dont know whats going wrong. </p>