Hi,@Maryam
Thanks for posting your question in the Microsoft Q&A forum.
Based on the screenshot you provided, you can see that Exchange is unable to connect to the Microsoft Exchange Active Directory topology service.
When the error occurs, please have a go by manually starting the "Microsoft Exchange Active Directory Topology service" and see if it could help.
Second method: the following blog shares a solution and in the comments section, a user mentioned that after adding the key MinSuitableServer = “1” as suggested in the blog to the Microsoft.Exchange.Directory. TopologyService.exe.config file and then error 4027 stopped (“I added that key and then 4027 and 2142 stopped and all exchange servers worked.”) :)
Exchange 2013 Setup Fails With Error "An exception ocurred while setting shared config DC"
So I would recommend have a look at the article and give it a try to see the result.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".