@Taranjeet Malik glad to see you were able to resolve your issue. Thanks for posting your solution so that others experiencing the same thing can easily reference this.
Since the Microsoft Q&A community has a policy that the question author cannot accept their own answer, they can only accept answers by others, I'll repost your solution in case you'd like to Accept the answer.
Issue: The APIM deployment failed with following error:
The resource write operation failed to complete successfully, because it reached terminal provisioning state 'Failed'.","details":[{"code":"ActivationFailed","message":"API Management service uses Azure SQL Server internally to store configuration for your service.\nThe service deployment failed to connect to an Azure SQL Server on port 1433 from inside the Virtual Network. \n 1. Please ensure an Azure SQL Server DNS can be resolved, if using a Custom DNS Server.\n2. Please ensure that there is no NSG / Firewall blocking outbound port access on 1433 from the Virtual Network subnet where deployment is being attempted.\nPlease review other common network configuration and troubleshooting information at https://aka.ms/apim-vnet-common-issues
Resolution: OP was able to get through this by following the below:
- Allow ports listed here for Azure SQL, Azure Storage and Azure Key Vault in Azure Firewall. This is to allow APIM Subnet to be able to reach these services (although Service Endpoints were enabled for these services, we still need Azure Firewall exceptions).
- Allowing UDP Protocol for DNS (port 53) traffic to DSN Service (Windows AD DS integrated running in Hub Subscription. This exception is to be created on NSG attached to APIM subnet, NSG attached to subnet where DNS service is running and in Azure Firewall (if it is configured to inspect all the traffic from spokes to hub).