1

I have a program where I build an envelope based on an HTTP Request. My next step is to take this envelope and add it to the Storage Queue so that I can then add the payload from the envelope to a Cosmos DB. It seems as if I am unable to connect to my Storage Account.

This is my code that actually sends the envelope to the Storage account:

import com.azure.storage.queue.QueueClientBuilder;
import com.azure.storage.queue.models.QueueStorageException;
import com.azure.storage.queue.QueueClient;


public class StorageQueueSend {
    public static String send(CfLog envelope) {
        try {
            QueueClient queueClient = new QueueClientBuilder()                              
               .connectionString("AzureWebJobsStorage")
               .queueName("hyperscalerapistorage-queue")
               .buildClient();
            queueClient.sendMessage(envelope.toString());
            return "Envelope added to storage queue\n";
        } catch(QueueStorageException e) {
            return e.getMessage();
        }
    }
}

hyperscalerapistorage-queue is the name of my queue. My connection string is stored in my local.settings.json as "AzureWebJobsStorage". And I have the proper connection string also stored in an Application Setting called "AzureWebJobsStorage" in my Function App. Here is the error message I am receiving:

[2023-02-23T20:15:59.682Z] Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.create'. System.Private.CoreLib: Exception has been thrown by the target of an invocation. Azure.Storage.Queues: No valid combination of account information found.
[2023-02-23T20:15:59.691Z] Error indexing method 'Functions.create'
[2023-02-23T20:15:59.696Z] Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.create'. System.Private.CoreLib: Exception has been thrown by the target of an invocation. Azure.Storage.Queues: No valid combination of account information found.
[2023-02-23T20:15:59.708Z] Function 'Functions.create' failed indexing and will be disabled.
[2023-02-23T20:16:00.022Z] Listening for transport dt_socket at address: 5005
[2023-02-23T20:16:00.077Z] The 'create' function is in error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.create'. System.Private.CoreLib: Exception has been thrown by the target of an invocation. Azure.Storage.Queues: No valid combination of account information found.
2
  • You're not reading from local.settings.json in your code; you're passing the literal string "AzureWebJobsStorage" as your connection string. You need to read it from your settings file first. Commented Feb 24, 2023 at 5:11
  • This did not work for me. I have put my connection in a different variable name and called System.getenv("hyperScalerAPIStorageQueue") in order to receive the connection string and I still get the same error. (I also did sysout println System.getenv("hyperScalerAPIStorageQueue") to ensure that the connection string is correct) Commented Feb 27, 2023 at 16:58

1 Answer 1

-1

you have to use Environment.GetEnvironmentVariable("app setting variable name"). also i would recommend to use a different storage account than the web job storage account

Sign up to request clarification or add additional context in comments.

2 Comments

This is precisely what I already stated in my comment, posted yesterday. Also, you gave a c# example, not Java. Note that the question should be closed (it was essentially a typo), which is why I did not post a formal answer.
This did not work for me. I have put my connection in a different variable name and called System.getenv("hyperScalerAPIStorageQueue") in order to receive the connection string and I still get the same error. (I also did sysout println System.getenv("hyperScalerAPIStorageQueue") to ensure that the connection string is correct)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.