Next generation of Internet of Things (IoT) services imposes stringent requirements to the future networks that current ones cannot fulfill. 5G is a technology born to give response to those requirements. However, the deployment of 5G is also accompanied by profound architectural changes in the network, including the introduction of technologies like multi-access edge computing (MEC), software defined networking (SDN), and network function virtualization (NFV). In particular, NFV poses diverse challenges like virtual network function (VNF) placement and chaining, also called VNF-mapping. In this paper, we present an algorithm that solves VNF-placement and chaining in a metro WDM optical network equipped with MEC resources. Therefore, it solves the VNF-mapping in conjunction with the virtual topology design of the underlying optical backhaul network. Moreover, a version of the method providing protection against node failures is also presented. A simulation study is presented to show the importance of designing the three problems jointly, in contrast to other proposals of the literature that do not take the design of the underlying network into consideration when solving that problem. Furthermore, this paper also shows the advantages of using collaboration between MEC nodes to solve the VNF-mapping problem and the advantage of using shared protection schemes. The new algorithm outperforms other proposals in terms of both service blocking ratio, and number of active CPUs (thus reducing energy consumption). Finally, the impact of deploying different physical topologies for the optical backhaul network is also presented.