Asp.net core 2.2 Web API无服务器化:APIM部署方案是否合理?
Great question—let’s clear up this misunderstanding right away, because you absolutely can build a serverless, pay-per-call API architecture with APIM without needing to deploy to App Service first. Your initial approach is off track, so here’s how to adjust it:
Skip App Service entirely: Use Azure Functions as your serverless backend
ASP.NET Core 2.2 can be packaged as an Azure Function (you can either refactor your API into Functions or publish your existing ASP.NET Core app as a Function App—both are supported in 2.2). Functions operate on a pure pay-per-call model: you only pay for compute time when your API is actually invoked, with no idle costs.Integrate Azure Functions directly with APIM
APIM has native support for importing Azure Functions as backend services. You don’t need an intermediate App Service layer. Once your Function App is deployed, you can:- In the APIM portal, add a new API and select the "Azure Function" option
- Connect your Function App to APIM, configure routing, policies, and authentication rules
- All API traffic will flow through APIM to your Function App, keeping the entire stack serverless and pay-per-call for the backend.
About APIM with VNet costs
If your requirement for VNet integration means you need to use an APIM tier that supports virtual networks (like Premium or Developer tiers for testing), that £1500 cost is unavoidable for that feature. However, by ditching App Service, you eliminate that recurring cost entirely—so your overall expense will be lower than your initial proposed setup.Alternative: Azure Container Apps (if you want to keep your ASP.NET Core app as-is)
If you don’t want to refactor into Functions, you can deploy your ASP.NET Core 2.2 API to Azure Container Apps with serverless scaling (pay-per-use). APIM can also integrate directly with Container Apps as a backend, maintaining the pay-per-call/serverless model without App Service.
In short: Your original assumption that you need App Service with APIM is incorrect. By pairing APIM with Azure Functions (or Container Apps), you can achieve the serverless, pay-per-call architecture you’re targeting while cutting out unnecessary App Service costs.
内容的提问来源于stack exchange,提问作者Manish Joisar

