Hi @md-infogr8 you're the "ResourceNameAlreadyInUse" error because the POST
method is being used. According to the Azure documentation, POST
is typically used to create new resources, and it might not handle updates as expected.
Before attempting to create the index again, verify if it already exists in your Azure Search service. You can use the following az rest
command:
az rest -m get https://[service-name].search.windows.net/indexes/search-index?api-version=2024-07-01 --headers api-key=[api-key]
This command will return a response code of 200 if the index exists, and an error code if it doesn't.
Next, to update an existing index, you should use the PUT
method instead of POST
. Here's how you can modify your command:
az rest -m put -u https://[service-name].search.windows.net/indexes/search-index?api-version=2024-07-01 --body "{'name':'search-index'}" --headers Content-Type=application/json api-key=[api-key]
This should update the index if it already exists, and create it if it doesn't.
Hope that helps. Please let us know if you've more questions.
-Grace