Hi So Yon Lee,
Since the Microsoft Q&A community has a policy that the question author cannot accept their own answer. They can only accept answers by others, Summarized and posted the solution that you shared, request you to Accept the answer, it will benefit the community find the answers quickly.
Scenario:
You are encountering the error message: "System.Data.Common: Format of the initialization string does not conform to specification starting at index 0." This typically indicates an issue with the format of your connection string.
Issue:
While following the exercise to run the server application, it seems that the connection string for Azure Cosmos DB might be incorrectly formatted.
Things Tried:
You have copied the sample local.settings.json
correctly and replaced the values for AzureWebJobsStorage
and COSMOSDB_CONNECTION_STRING
as instructed but are still facing the error.
Solution shared by So Yon Lee
Resolution:
To resolve this issue, ensure that your COSMOSDB_CONNECTION_STRING
is formatted correctly. It should adhere to the following structure:
COSMOSDB_CONNECTION_STRING="AccountEndpoint=<your-cosmosdb-URI>;AccountKey=<your-account-key-here>"
Make sure to replace <your-cosmosdb-URI>
and <your-account-key-here>
with the actual values provided in your Azure Cosmos DB account.
Example of a correctly formatted local.settings.json
:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "<STORAGE_CONNECTION_STRING>",
"FUNCTIONS_WORKER_RUNTIME": "node",
"AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
"COSMOSDB_CONNECTION_STRING": "AccountEndpoint=https://your-cosmosdb-uri;AccountKey=your-account-key;"
},
"Host": {
"LocalHttpPort": 7071,
"CORS": "http://localhost:3000",
"CORSCredentials": true
}
}
Ensure there are no extra spaces or characters in the connection string, as these can also lead to initialization errors.