Azure Blob Storage not connecting with App Service

sayam sanghvi 20 Reputation points
2024-03-25T04:05:38.57+00:00

So I have an Azure blob storage and I have enabled access restriction on it and only tried allowing my app service. I have added CORS on Azure Blob for the same App service Id. Now when I send in a request I see that the entire code gets executed in my logs. The code has two parts on sequelize transaction and within this sequelize transaction I have the upload of an image. In logs its clearly visible that the sequelize transaction gets committed but the API on Postman is throwing a 502 "Bad Gateway" error.

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,834 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,743 questions
0 comments No comments
{count} votes

Accepted answer
  1. Anand Prakash Yadav 7,785 Reputation points Microsoft Vendor
    2024-03-25T11:10:23.4333333+00:00

    Hello sayam sanghvi,

    Thank you for posting your query here!

    Adding on to the previous response, a 502 Bad Gateway error indicates that the server acting as a gateway or proxy received an invalid response from an upstream server it accessed to fulfill the request.

    The issue you’re experiencing could be due to a few different factors.

    Please make sure that you have allowed your App Service to access your Blob Storage account. You can do this by adding your App Service's outbound IP addresses to the allowed list on Blob Storage.

    Also, check the CORS settings on Blob Storage. Make sure that you have enabled CORS for your App Service's domain or URL. You can also specify the allowed methods, headers, and max age for CORS requests.

    Other possible reasons for 502 errors can be application-level issues such as the application using high memory/CPU, or the application crashing due to an exception. https://learn.microsoft.com/en-us/azure/app-service/troubleshoot-http-502-http-503

    You might also consider using a managed identity to access Azure Blob Storage from your Azure App Service that can simplify authentication and access management.

    Similar post: https://learn.microsoft.com/en-us/answers/questions/895845/app-service-cannot-write-to-blob-storage

    Do let us know if you have any further queries. I’m happy to assist you further.

    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Sedat SALMAN 13,825 Reputation points
    2024-03-25T06:44:44.8833333+00:00

    there is troubleshooting document for 502 error please check first the following document

    https://appserviceblog.com/en/troubleshoot-http-error-of-502-bad-gateway-and-503-service-unavailable-in-azure-app-service/

    Additionally, Azure App Service provides diagnostic tools through the "Diagnose and solve problems" blade in the Azure Portal. These tools can help identify specific issues with your app and suggest potential fixes

    https://learn.microsoft.com/en-us/azure/app-service/troubleshoot-http-502-http-503


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.