Is it a good idea to buy second hand bike model that has been discontinued? I am a new rider looking for a road bike.  I found a deal to buy second hand 2017 Orbea Avant M40 size 51 for $800.  I see that this model is discontinued by Orbea. Will it be a problem to find parts should I need some repairs done in near future?  

My last bike was Diamondback Calico - Aluminum frame. I had problem going up on steep hills. At max I have rode a bike for 20 miles in one ride, and my average in the summer would be anywhere from 10 to 25 miles.  This year planning to ride for a 40 miles ride.
Generally it's absolutely fine to buy a relatively new bike, and not worry about component availability.

Bicycles are not like cars that have specific components for each model, or at best some component sharing across a manufacturers models. In general, practically all bicycle components are standardized so that bicycles can be built up (or modified) with components from many manufacturers. 

There is an increasing trend for some manufacturers to integrate the seatpost, stem and sometimes handlebars of some models into the frame design for aerodynamics or to facilitate internal cable routing, but the Orbea model you mentioned does not have this.