My App Service (A) sends a POST request that contains a base64 encoded file to App Service B . I understand that this may seem strange, but it is needed in this case. App Service B uploads it to a Blob Storage and then returns a response. The size of the file is between 40-80mb.
The problem is that the file upload is really slow (sometimes longer than two minutes). I am trying to understand why it is so slow. I would assume that the network bandwith is quite high (the two app services are in the same region). Both app services use the S1 tier.
Here is the simplified code:
App service A Controller:
private static async Task UploadFileToAppServiceB(HttpClient client, string fileName, byte[] fileContent)
{
var path = $"www.foo.bar/upload";
var request = new
{
FileName = fileName,
Content = fileContent,
};
client.Timeout = TimeSpan.FromMinutes(2);
var response = await HandleNotFound(client.PostAsJsonAsync(path, request));
response.EnsureSuccessStatusCode();
}
App Service B Controller:
[HttpPost("upload")]
[RequestSizeLimit(209715200)]
public async Task UploadFileToBlobStorage([FromBody] FooFile fooFile)
{
var fileContent = fooFile.Content;
var blobContainerClient = GetContainerClient();
var blobClient = blobContainerClient.GetBlobClient();
await using var memoryStream = new MemoryStream(fileContent);
await blobClient.UploadAsync(memoryStream, true);
}
Why does App Service B take so long to respond? Is there a way I can improve this?