Pietro
Pietro

Reputation: 781

Is it possible to deploy only updated Azure Function Projects when I push a repo of the entire Solution?

I need to refactor a .Net Web API, I'm considering moving to serverless and I'm trying to understand the best option to migrate the code to Azure Functions.

As far as I understand the correct approach to reduce costs and cold start time is to split the API: it is much better to have many small web api than a single one with all methods. Small api consume less memory and cold start quicker.

Having more Functions in the same Project does not resolve the problem as they would be all deployed in the same Function App so one dll, high memory, slow cold start. So I should create several Azure Function Projects and deploy each of them in a different Function App.

If all the above is correct we finally got to the problem: I would structure the code and the repo so that I have one Solution containing several Azure Function Projects. How can I have a CI/CD (Azure DevOps) so that when I push the repo ONLY the Azure Function Projects updated/modified/new are deployed? I need to deploy only the modified Azure Function Projects so not to have all the Function Apps (also the ones whose code is unchanged) goes cold.

This is less important but I'd also need to have one URL for all APIs, so https://myapi.azurewebsites.net/api/Function1, https://myapi.azurewebsites.net/api/Function2, etc and not https://myapi1.azurewebsites.net/api/Function1, https://myapi2.azurewebsites.net/api/Function1, etc. Is this possible using the above structure?

Upvotes: 2

Views: 520

Answers (1)

Krzysztof Madej
Krzysztof Madej

Reputation: 40729

You need to have multiple CI/CD pipelines with trigger limited only to specific folder:

trigger:
  paths:
    include:
    - function-a/*
    exclude:
    - '*'

for this you will get pipeline triggered only if changes are done in function-a folder. To limit a work needed to develop pipelines you should consider using templates. You can find more info about this here:

In this way you will avoid repeating yourself.

EDIT

To unify your API you can use Azure Functions Proxies

With this feature, you can specify endpoints on your function app that are implemented by another resource. You can use these proxies to break a large API into multiple function apps (as in a microservice architecture), while still presenting a single API surface for clients.

Upvotes: 2

Related Questions