Azure-sdk-for-net: [QUERY] Status 404 with AppConfiguration ConfigurationClient in Azure Functions

Created on 10 Nov 2020  路  6Comments  路  Source: Azure/azure-sdk-for-net

Query/Question
I'm using the App Configuration SDK (Azure.Data.AppConfiguration 1.0.2) in an Azure Function.
The Azure Function is a timer triggered functions that implement the syncronization between two different App Configuration instances.
I use Event Grid to dispatch events generated by my primary App Configuration to a queue. Every time the function runs, it retrieves the messages in the queue and, using two ConfigurationClient (one for the primary and one for the secondary App Configuration) update the settings.

The code is the following

string queueConnectionString = Environment.GetEnvironmentVariable("SyncQueueConnectionString");
var queueClient = new QueueClient(queueConnectionString, "syncqueue");
if (queueClient.Exists())
{
     string appConfigPrimaryConnectionString = Environment.GetEnvironmentVariable("AppConfigPrimaryConnectionString");
     string appConfigSecondaryConnectionString = Environment.GetEnvironmentVariable("AppConfigSecondaryConnectionString");

     var appConfigPrimaryClient = new ConfigurationClient(appConfigPrimaryConnectionString);
     var appConfigSecondaryClient = new ConfigurationClient(appConfigSecondaryConnectionString);

     var response = await queueClient.ReceiveMessagesAsync(10);
     foreach (var message in response.Value)
     {
           var base64EncodedBytes = Convert.FromBase64String(message.MessageText);
           var @event = JsonConvert.DeserializeObject<Event>(Encoding.UTF8.GetString(base64EncodedBytes));

          if (@event.IsKeyValueModified())
          {
               var primarySetting =  await appConfigPrimaryClient.GetConfigurationSettingAsync(@event.Data.key, @event.Data.label);
               await appConfigSecondaryClient.SetConfigurationSettingAsync(primarySetting);
          }
          else if (@event.IsKeyValueDeleted())
          {
              await appConfigSecondaryClient.DeleteConfigurationSettingAsync(@event.Data.etag, @event.Data.label);
          }

         await queueClient.DeleteMessageAsync(message.MessageId, message.PopReceipt);
    }
}

I receive the following error when I call the method GetConfigurationSettingAsync :

Service request failed.
Status: 404 (Not Found)

Headers:
Server: openresty/1.17.8.2
Date: Tue, 10 Nov 2020 18:17:56 GMT
Connection: keep-alive
x-ms-request-id: REDACTED
x-ms-client-request-id: a1d08379-b9e6-4657-b044-d635a542dce1
x-ms-correlation-request-id: a1a2c2ed-ed9e-4409-b506-4af816e15509
x-ms-tenant-name: REDACTED
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Expose-Headers: REDACTED
Strict-Transport-Security: max-age=15724800; includeSubDomains
Content-Length: 0

If I try the same code in a console project, the code works fine.
The connections strings are right.

Thanks

Environment:

  • Name and version of the Library package used: [e.g. Azure.Data.AppConfiguration 1.02, Azure.StorageQueues 12.4.2]
  • Hosting platform or OS and .NET runtime version (dotnet --info output for .NET Core projects): [e.g. .NET Core 3.1 on Azure Function Runtime 3.0.14916.0]
  • IDE and version : [e.g. Visual Studio 2019]
App Configuration Client customer-reported needs-team-attention question

All 6 comments

Thank you for your feedback. Tagging and routing to the team member best able to assist.

@massimobonanni Thanks for all the information.
Does that means that when you run the Azure Function locally you get the expected behavior, but when you publish your project to Azure you start getting 404?

I'm also looking at the service documentation, and if you are getting 404 from GetConfigurationSettingAsync it means that the key and label combination was not found.
Are you testing your code with a static queue? I wonder if every time you are testing, values are different and there could be a key-label that doesn't exist in appConfigPrimaryClient

Hi, I receive the 404 locally. I don't remember if I received the same when I publish the function. I will check asap. I use a static queue in the storage (it is always the same). The same code, outside the function (in a console project), works perfectly.

Hi, Mariana.
I tried again both locally than in Azure and now the function works fine (in both environments). I don't receive the previous error. I don't know what is changed until the day I published the post but now it works. Just to be sure I checked in the App Insight for the error and I find the exceptions I mentioned in the post last time I make the test.
I'm sorry for the post and to use your time. We can consider the issue as a solved issue.

Max

I am glad it is working. Closing issue then

Was this page helpful?
0 / 5 - 0 ratings