Calling Azure pricing api from Azure App Service (Web App) not working.

Atanu Gupta 136 Reputation points


My task is to fetch the pricing related details by using the "" url of azure. I am using C# web api to get the pricing details for any azure service (say for example windows VM price).

public async Task<IActionResult> GetWindowsVmPrice(string currencyCode, string region, string size)
	string pricingBaseUrl = "";
	string requestUrl = $"{pricingBaseUrl}?currencyCode='{currencyCode.ToUpper()}'&$filter=serviceName eq 'Virtual Machines' " +
$"and armRegionName eq '{region}' and armSkuName eq '{size}' and type eq 'Consumption' " +
$"and  (skuName eq '{sName.Trim()}' or skuName  eq '{size}') and contains(productName, 'Windows')";

	using HttpClient client = new HttpClient();
	var response = await client.GetAsync(requestUrl);
	string content = await response.Content.ReadAsStringAsync();
	var results = JsonConvert.DeserializeObject<JObject>(content);

	return Ok(results);

The code is working fine and I am getting the expected result when running it localhost swagger. Now the problem starts when I host this service in Azure App Service. The swagger there giving the result as 200 OK but with an empty [] json.

So, what is the problem in Azure when the same code is running fine in localhost.

Please advise if I am missing anything. Do I need to enable something in Azure or in the code or else. I am lost here as there is no error. Thanks.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
5,677 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Atanu Gupta 136 Reputation points

    Never mind! Solved it by myself 👍