3
votes

I am beginning development with Azure functions. Ive been able to connect to my actual azure Storage account Queue for testing how to program with Azure functions. Now my next step is to use the Microsoft Azure Storage Explorer to use the Local storage account so I do not have to be connected to azure. I saw how to do it in this article: https://docs.microsoft.com/en-us/azure/storage/storage-configure-connection-string#create-a-connection-string-to-the-storage-emulator

in the appsettings.json I changed my values to this exactly:
{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==",
    "AzureWebJobsDashboard": "",
    "StorageConnectionString": "UseDevelopmentStorage=true"

  }
}

When i start up the Azure Fuctions CLI using Visual Studio i get this error message:

ScriptHost initialization failed Microsoft.WindowsAzure.Storage: The remote server returned an error: (403) Forbidden.

Has anyone encountered this?

1
Here's a blog about this: blog.kloud.com.au/2016/12/02/… Fiddler might capture useful info about why the request failed as wellMatt Mason

1 Answers

7
votes

Please change the following line of code:

"AzureWebJobsStorage": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="

to either:

"AzureWebJobsStorage": "UseDevelopmentStorage=true"

or:

"AzureWebJobsStorage": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;
AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;
    BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;
    TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;
    QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;"

That should take care of 403 error.

Basically storage emulator has different endpoints than the cloud storage account. For example, the default blob endpoint for a cloud storage account is http://[youraccount].blob.core.windows.net while the blob endpoint for storage emulator is http://127.0.0.1:10000. When you just specify the storage account name and key for the storage emulator in your connection string, storage client library treats it like a cloud storage account and tries to connect to http://devstoreaccount1.blob.core.windows.net using the account key you provided. Since the key for devstoreaccount1 in the cloud is not the one you provided, you are getting 403 error.