0

I have created blob triggered azure function and while connecting it to azure I am getting error as "No valid combination of account information found". Here is my code sample

CloudStorageAccount StorageConn;  
CloudBlobClient BlobClient; 
StorageConn = CloudStorageAccount.Parse(Environment.GetEnvironmentVariable("MyConn")); 
BlobClient = StorageConn.CreateCloudBlobClient(); 
BlobServiceClient blobServiceClient = new BlobServiceClient(StorageConn.ToString());//At this line I am getting the error;

and in local.settings.json:

{
    "IsEncrypted": false,
    "Values": {     
       "MyConn": "DefaultEndpointsProtocol=https;AccountName=***;AccountKey=***",
     } 
}

Error Screen

Viveka
  • 340
  • 2
  • 14

2 Answers2

1

Your connection string is not complete: it misses the EndPointSuffix. Although documentation states this is only needed 'for a storage service in regions or instances with different endpoint suffixes', it seems this is necessary for storage accounts in all regions now.

To create a connection string for a storage service in regions or instances with different endpoint suffixes, such as for Azure China 21Vianet or Azure Government, use the following connection string format.

To make sure you have the correct connection string, you can

  1. Go to the Azure portal
  2. Navigate to the storage account
  3. Go to Security + Networking -> Access Keys
  4. Click 'Show keys' on the top left corner
  5. Copy either of the Connection Strings

A complete connection string for the general Azure cloud looks something like this:

DefaultEndpointsProtocol=https;AccountName=***;AccountKey=**;EndpointSuffix=core.windows.net

EDIT:
Please also double check there are no whitespace characters in the connection string. That might break things for you.

rickvdbosch
  • 14,105
  • 2
  • 40
  • 53
  • I tried this but still the issue is not resolved – Viveka Oct 27 '21 at 06:24
  • Please provide us with a bit more information than "it's not working". Put a breakpoint, investigate the connection string that is resolved runtime and add (relevant) details to the question. – rickvdbosch Oct 27 '21 at 06:48
0

Can you try with below connection string

{
    "MyConn": "DefaultEndpointsProtocol=https;AccountName=***;AccountKey=***;EndpointSuffix=core.windows.net"
}
rickvdbosch
  • 14,105
  • 2
  • 40
  • 53
vivek jain
  • 291
  • 3
  • 13