I've tried to update my Azure cloud functions to the newest versions and received following error on startup:
[2023-03-16T07:43:24.025Z] Executed 'Functions.legendDataHubUpdated' (Failed, Id=b932d0c6-5f2d-4bb8-aabc-15fs6697f2ba, Duration=82ms)
[2023-03-16T07:43:24.025Z] System.Private.CoreLib: Exception while executing function: Functions.legendDataHubUpdated. Microsoft.Azure.WebJobs.Extensions.CosmosDB: The CosmosDB connection string must be set either via the 'CosmosDB' IConfiguration connection string, via the CosmosDBAttribute.ConnectionStringSetting property or via CosmosDBOptions.ConnectionString.
These are my dependencies:
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-cosmos</artifactId>
<version>4.41.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure.functions</groupId>
<artifactId>azure-functions-java-library</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.3.0-beta.2</version>
</dependency>
<dependency>
<groupId>com.azure.resourcemanager</groupId>
<artifactId>azure-resourcemanager</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-blob</artifactId>
<version>12.21.0</version>
</dependency>
And this is my function with the annotations:
@FunctionName("legendDataHubUpdated")
@StorageAccount("CUSTOM_BLOB_CONNECTION_STRING")
public void legendDataHubUpdated(
@BlobTrigger(name = "xmlFileContent", path = AppConstants.COSMOS_CONFIG_CUSTOM_BLOB_CONTAINER_NAME +
"/{folderName}/{fileName}.xml", dataType = "string") String xmlFileContent,
@BindingName("fileName") String fileName,
@BindingName("folderName") String folderName,
@CosmosDBOutput(name = "junctionObject",
databaseName = AppConstants.COSMOS_CONFIG_DB_NAME_1,
containerName = AppConstants.COSMOS_CONFIG_CONTAINER_NAME_CUSTOM_JUNCTION,
connection = AppConstants.COSMOS_CONFIG_WRITE_CONN_STRING) OutputBinding<QuestionnaireJunctionObject> result,
final ExecutionContext context
) {
// Doing stuf here with the result
}
Do you have any ideas how to fix this?
The Cosmos DB input changes the following variables in the newer version, I don't know whether this affects the functionality: collectionName -> containerName connectionStringSetting -> connection