During deploy, azd first discovers all the resource groups that make up your application by looking for groups tagged with azd-env-name and with a value that matches the name of your environment. Then, it enumerates all the resources in each of these resource groups, looking for a resource tagged with azd-service-name with a value that matches the name of your service from azure.yaml.
While we recommend using tags on resources, you can also use the resourceName property in azure.yaml to provide an explicit resource name. In that case, the above logic isn't run.