Yes, one way to create an App Service and an Azure SQL database in Azure in an automated way is by using Azure REST APIs
Use the Azure Resource Manager REST API to create the Azure SQL database server and database
- https://docs.microsoft.com/en-us/rest/api/sql/servers/createorupdate
- https://docs.microsoft.com/en-us/rest/api/sql/databases/createorupdate
Use the Azure Resource Manager REST API to create the App Service
Update the connection string for the App Service to point to the Azure SQL database.
Note that there are also other ways to create Azure resources in an automated way, such as using Azure CLI, Azure PowerShell, or Azure Resource Manager templates.