azure-search-openai-demo icon indicating copy to clipboard operation
azure-search-openai-demo copied to clipboard

unable to find a resource tagged with 'azd-service-name: backend'.

Open MichaelKMorrison opened this issue 2 years ago • 15 comments

This issue is for a: (Deployment)

- [X] bug report -> please search issues before submitting

### Minimal steps to reproduce
Downloaded and deployed via the /Code page instructions, then ran "azd up" 

### Any log messages given by the failure
>Deploying services (azd deploy)

  (x) Failed: Deploying service backend

ERROR: getting target resource: resource not found unable to find a resource tagged with 'azd-service-name: backend'. Ensure the service resource is correctly tagged in your infrastructure configuration, and rerun provision.

### Expected/desired behavior
> Would expect it to just work.  
Files referenced?
main.bicep	tags: union(tags, { 'azd-service-name': 'backend' })
Azure.yaml	project: ./app/backend

### OS and Version?
> Windows 10

### azd version?
> run `azd version` and copy paste here.

### Versions
> 1.2.0 (commit 99ea7577f0df0df2ba34b677da189fafba18c0f7) 
All fresh installs of Python, GIT and Node.js

### Mention any other details that might be useful

> ---------------------------------------------------------------
> Thanks! We'll be in touch soon.

MichaelKMorrison avatar Aug 23 '23 02:08 MichaelKMorrison

Hm, that's quite peculiar. Can you login to the Azure Portal for the resource group, open the App Service in that group, and inspect the tags? You should see a tag for azd-service-name: backend. Here's what it looks like for me:

Screenshot 2023-08-22 at 7 21 50 PM

pamelafox avatar Aug 23 '23 02:08 pamelafox

@MichaelKMorrison , I can see from the bug-description that you ran azd up, but the provided log looks more like running azd deploy (as there's no any log lines before the >Deploying services (azd deploy)).

Can you confirm if you are getting this error when running azd up ? and if yes, can you share the complete log messages?

vhvb1989 avatar Aug 29 '23 01:08 vhvb1989

I have the same issue - seems to be triggered if you replace 'azd-service-name: backend' with your custom tag which could be anything, on the App Service - line 123 \infra\main.bicep . For me , for both azd up as well as azd deploy If you do not touch the Tag the deploy has no issues.

delicpsyche avatar Sep 04 '23 14:09 delicpsyche

That tag must match the service name in azure.yaml, otherwise AZD doesn't know where to deploy your code.

pamelafox avatar Sep 04 '23 14:09 pamelafox

Yep - that is what I had done , though it was still complaining . Re-init , then changing tag/service name resolved it.

delicpsyche avatar Sep 10 '23 17:09 delicpsyche

Hi @delicpsyche , can you please explain in detail how you resolved the problem. Because I have successfully deployed the architecture once but I want to make few more changes to the code and deploy another app using same resources, I am able to use the rest of the resources in the way I need but I am facing a trouble using the app service where I have changed the backend URI(in .env file), and the tag 'azd-service-name: backend'. Can you help me on this? thank you .

suma-sai-paluri avatar Sep 21 '23 09:09 suma-sai-paluri

I am also having the same problem. I deleted the service from my resource group and now it gives this "resource not found" message when I use azd deploy or azd up.

marceloricciardi avatar Sep 21 '23 23:09 marceloricciardi

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this issue will be closed.

github-actions[bot] avatar Nov 21 '23 01:11 github-actions[bot]

I am still getting this error to this day when the tags are named as they should.

VagifMesmerise avatar Dec 04 '23 10:12 VagifMesmerise

Can you provide more details? Screenshot of your app service app tags from Portal? Did you run azd up? Did you make any changes to azure.yaml or bicep files? Do you have multiple azd envs?

pamelafox avatar Dec 05 '23 05:12 pamelafox

Happens to me too, I just can tell you that it seems to happen with azd deploy and up, only one environement is used, bicep etc. is changed, but not the tags or the azure.yaml (and most of the time it works, just at some point it starts failing). The tags in azure are also fine and were not changed. I also had a look in the azd package code, maybe it has to do something more with the azd package and its get resource by tag functionality that seems to be used? Because it happens without changing anything, It happened 2-3 times now.

Has anyone any other idea what it could be?

leanderkunstmann avatar Dec 07 '23 09:12 leanderkunstmann

Yes I have done azd up. The only method I have found to help is to change the tag on azure and on infra/yaml to something new and that works at times.

VagifMesmerise avatar Dec 07 '23 10:12 VagifMesmerise

I can offer some additional information -> changing the appservice (for example increasing the appservice plan) could have caused the issue, I am not sure. What fixed it was running azd up (where I had to set a variable for a higher appservice plan) then it worked again just fine. Maybe a reachability problem of the appservice itself, as there have been some issues in westeurope lately (e.g. the basic plan (b1) often did not work at all) ?

leanderkunstmann avatar Dec 07 '23 12:12 leanderkunstmann

I am not running azd up as I do not want my resource to be updated with empty data. The tag does match the one on Azure I can confirm. The same exact code with tags worked fine yesterday, but will not work today. This is most likely an issue from Azure side of things. There is only one azn env file.

VagifMesmerise avatar Dec 21 '23 10:12 VagifMesmerise

Hi @delicpsyche , can you please explain in detail how you resolved the problem. Because I have successfully deployed the >architecture once but I want to make few more changes to the code and deploy another app using same resources, I am able to >use the rest of the resources in the way I need but I am facing a trouble using the app service where I have changed the backend >URI(in .env file), and the tag 'azd-service-name: backend'. Can you help me on this? thank you .

I can confirm was VagifMesmerise says.

I have the exact same issue .. never touched service name "backend" in azure.yaml and as well not in bicep az web app resource. Also for both i have "backend" present in code and visible in azure portal as well at the az web app resource

I am running "azd deploy --debug" to deploy only the updated webb app on an already successfully running infra a setup and with an older versioni want to update

cforce avatar Sep 27 '24 10:09 cforce

This error still persists. No matter what configuration changes or tag changes we do.

reeshabh90 avatar Dec 09 '24 09:12 reeshabh90

@reeshabh90 Are you doing App Service or Container Apps deployment? Can you look in the Portal for your resource group, find the target App Service or Container App, confirm it has the tag, and then check that your azure.yaml has the correct host selected (appservice vs containerapp)?

pamelafox avatar Dec 09 '24 20:12 pamelafox

@minlength(1) param environmentName string = ''

param snowAppId string = '' param appServicePlanName string param resourceGroupName string param apiServiceName string param keyVaultServiceName string param appServiceSkuName string // Set in main.parameters.json

var abbrs = loadJsonContent('abbreviations.json') var resourceToken = tolower(uniqueString(subscription().id, environmentName)) var tags = { 'azd-service-name': 'api' 'Env': 'Dev' 'fin_snowappid': snowAppId }

// Create a resource group resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { name: resourceGroupName location: location tags: tags }

// Deploy the chatgum-api module chatgmapi 'core/host/appservice.bicep' = { name: 'web' scope: resourceGroup params: { name: empty(apiServiceName) ? apiServiceName : '${abbrs.websitesAppService}' location: location tags: tags runtimeName: 'python' runtimeVersion: '3.12' appCommandLine: 'python3 -m gunicorn main:app' scmDoBuildDuringDeployment: true managedIdentity: true use32BitWorkerProcess: appServiceSkuName == 'F1' alwaysOn: appServiceSkuName != 'F1' appSettings: { AZURE_ENV_NAME: environmentName AZURE_LOCATION: 'westus' AZURE_RESOURCE_GROUP: resourceGroupName AZURE_KEY_VAULT_NAME: keyVaultServiceName DISABLE_SSL_VERIFY: 'True' APP_LOG_LEVEL: 'INFO' } } }

// Create an App Service Plan module appServicePlan 'core/host/appserviceplan.bicep' = { name: 'appserviceplan' scope: resourceGroup params: { name: appServicePlanName location: location sku: { name: appServiceSkuName capacity: 1 } } }

using for this i am face this issue how to best ways to solve this

soni811 avatar Dec 11 '24 05:12 soni811

@reeshabh90 Are you doing App Service or Container Apps deployment? Can you look in the Portal for your resource group, find the target App Service or Container App, confirm it has the tag, and then check that your azure.yaml has the correct host selected (appservice vs containerapp)?

I was doing app service deployment. I tried deleting existing app-service, deployed a fresh one with tags intact. Deployment was then successful.

reeshabh90 avatar Dec 12 '24 06:12 reeshabh90