we are planning to host more than one version of web-api, do I have to treat each version as a separate service?
You do not necessarily have to register them separate services. It is possible to advertise each instance under the same service name, and specify the API version for the given instance under the
meta key on the Service Definition. See the examples on that page for more detail.
You’ll then want to create a Prepared Query (one for each advertised version) to be used for service discovery via either the DNS or HTTP interfaces to return service instances that provide the desired version of the web API.
If you’re utilizing Connect, you can create a Service Router which routes the different HTTP paths (i.e.,
/v2) to specific service subsets associated with each API version. Service subsets are defined in a Service Resolver you create for the
web-api service. See L7 Traffic Management for more info.