Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw meaningful error if AzureWebJobsStorage is not a proper connection string #2268

Open
jtlz2 opened this issue Jun 25, 2019 · 2 comments
Milestone

Comments

@jtlz2
Copy link

jtlz2 commented Jun 25, 2019

Is your question related to a specific version? If so, please specify:

See below logging output

What language does your question apply to? (e.g. C#, JavaScript, Java, All)

Python

Question

My stackoverflow question (https://stackoverflow.com/questions/56737086/azure-functions-python-blobtrigger-how-do-i-fix-microsoft-azure-webjobs-extensi) refers

How do I fix "Microsoft.Azure.WebJobs.Extensions.Storage: Object reference not set to an instance of an object."?

I have successfully run Azure Functions using the local dev host in the past.

I have not been able to get the blobTrigger working recently. I have taken the following steps:

func init NewWave
cd NewWave
func new # -> select httpTrigger called HttpTrigger in language python
func new # -> select blobTrigger called BlobTrigger in language python
func host start

host.json contains:

{
    "version": "2.0",
    "extensionBundle": {
        "id": "Microsoft.Azure.Functions.ExtensionBundle",
        "version": "[1.*, 2.0.0)"
    }
}

local.settings.json contains:

{
  "IsEncrypted": false,
  "Values": {
    "FUNCTIONS_WORKER_RUNTIME": "python",
    "AzureWebJobsStorage": "{AzureWebJobsStorage}"
  }
}

AzureWebJobsStorage is a connection string set via an environment variable.

BlobTrigger/function.json contains:

{
  "scriptFile": "__init__.py",
  "bindings": [
    {
      "name": "myblob",
      "type": "blobTrigger",
      "direction": "in",
      "path": "samples-workitems/{name}",
      "connection": ""
    }
  ]
}

__init__.py contains:

import logging

import azure.functions as func


def main(myblob: func.InputStream):
    logging.info(f"Python blob trigger function processed blob \n"
                 f"Name: {myblob.name}\n"
                 f"Blob Size: {myblob.length} bytes")

HttpTrigger loads but BlobTrigger does not. The output is:

Azure Functions Core Tools (2.7.1373 Commit hash: cd9bfca26f9c7fe06ce245f5bf69bc6486a685dd)
Function Runtime Version: 2.0.12507.0
Warning: 'connection' property in '~/NewWave/BlobTrigger/function.json' is empty.
Skipping 'AzureWebJobsStorage' from local settings as it's already defined in current environment variables.
[...]
[6/24/19 12:45:28 PM] Starting JobHost
[...]
[6/24/19 12:45:28 PM] Generating 2 job function(s)
[6/24/19 12:45:28 PM] Found the following functions:
[6/24/19 12:45:28 PM] Host.Functions.HttpTrigger
[6/24/19 12:45:28 PM] Host.Functions.BlobTrigger
[6/24/19 12:45:28 PM]
[6/24/19 12:45:28 PM] Host initialized (280ms)

Http Functions:

	HttpTrigger: [GET,POST] http://localhost:7071/api/HttpTrigger

[6/24/19 12:45:28 PM] A host error has occurred
[6/24/19 12:45:28 PM] Microsoft.Azure.WebJobs.Extensions.Storage: Object reference not set to an instance of an object.
[6/24/19 12:45:28 PM] Stopping JobHost

What is causing this error and how can I resolve it?

If any further settings, logs etc. are required please advise in the comments below and I will update.

Thanks

OS: macOS High Sierra 10.13.6

Python version:

Python 3.6.8 |Anaconda, Inc.| (default, Dec 29 2018, 19:04:46)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

pip freeze:

azure==4.0.0
azure-applicationinsights==0.1.0
azure-batch==4.1.3
azure-cognitiveservices-vision-customvision==1.0.0
azure-common==1.1.20
azure-cosmosdb-nspkg==2.0.2
azure-cosmosdb-table==1.0.5
azure-datalake-store==0.0.45
azure-eventgrid==1.2.0
azure-functions==1.0.0b4
azure-functions-worker==1.0.0b8
azure-graphrbac==0.40.0
azure-keyvault==1.1.0
azure-loganalytics==0.1.0
azure-mgmt==4.0.0
azure-mgmt-advisor==1.0.1
azure-mgmt-applicationinsights==0.1.1
azure-mgmt-authorization==0.50.0
azure-mgmt-batch==5.0.1
azure-mgmt-batchai==2.0.0
azure-mgmt-billing==0.2.0
azure-mgmt-cdn==3.1.0
azure-mgmt-cognitiveservices==3.0.0
azure-mgmt-commerce==1.0.1
azure-mgmt-compute==4.6.2
azure-mgmt-consumption==2.0.0
azure-mgmt-containerinstance==1.4.1
azure-mgmt-containerregistry==2.8.0
azure-mgmt-containerservice==4.4.0
azure-mgmt-cosmosdb==0.4.1
azure-mgmt-datafactory==0.6.0
azure-mgmt-datalake-analytics==0.6.0
azure-mgmt-datalake-nspkg==3.0.1
azure-mgmt-datalake-store==0.5.0
azure-mgmt-datamigration==1.0.0
azure-mgmt-devspaces==0.1.0
azure-mgmt-devtestlabs==2.2.0
azure-mgmt-dns==2.1.0
azure-mgmt-eventgrid==1.0.0
azure-mgmt-eventhub==2.6.0
azure-mgmt-hanaonazure==0.1.1
azure-mgmt-iotcentral==0.1.0
azure-mgmt-iothub==0.5.0
azure-mgmt-iothubprovisioningservices==0.2.0
azure-mgmt-keyvault==1.1.0
azure-mgmt-loganalytics==0.2.0
azure-mgmt-logic==3.0.0
azure-mgmt-machinelearningcompute==0.4.1
azure-mgmt-managementgroups==0.1.0
azure-mgmt-managementpartner==0.1.0
azure-mgmt-maps==0.1.0
azure-mgmt-marketplaceordering==0.1.0
azure-mgmt-media==1.0.0
azure-mgmt-monitor==0.5.2
azure-mgmt-msi==0.2.0
azure-mgmt-network==2.7.0
azure-mgmt-notificationhubs==2.1.0
azure-mgmt-nspkg==3.0.2
azure-mgmt-policyinsights==0.1.0
azure-mgmt-powerbiembedded==2.0.0
azure-mgmt-rdbms==1.8.0
azure-mgmt-recoveryservices==0.3.0
azure-mgmt-recoveryservicesbackup==0.3.0
azure-mgmt-redis==5.0.0
azure-mgmt-relay==0.1.0
azure-mgmt-reservations==0.2.1
azure-mgmt-resource==2.1.0
azure-mgmt-scheduler==2.0.0
azure-mgmt-search==2.0.0
azure-mgmt-servicebus==0.5.3
azure-mgmt-servicefabric==0.2.0
azure-mgmt-signalr==0.1.1
azure-mgmt-sql==0.9.1
azure-mgmt-storage==2.0.0
azure-mgmt-subscription==0.2.0
azure-mgmt-trafficmanager==0.50.0
azure-mgmt-web==0.35.0
azure-nspkg==3.0.2
azure-servicebus==0.21.1
azure-servicefabric==6.3.0.0
azure-servicemanagement-legacy==0.20.6
azure-storage==0.36.0
azure-storage-blob==2.0.1
azure-storage-common==2.0.0
azure-storage-file==1.4.0
azure-storage-queue==1.4.0
msrestazure==0.6.0

@jtlz2
Copy link
Author

jtlz2 commented Jun 25, 2019

As per my SO answer (https://stackoverflow.com/a/56752240/1021819):

By trial and error - and a completely misleading error message...

The answer is simply to set the environment variable AzureWebJobsStorage to the Storage account's master Access key Connection string, which looks something like this:

DefaultEndpointsProtocol=https;AccountName=<account name>;AccountKey=<account key>;EndpointSuffix=core.windows.net

rather than the SAS Connection string created via az storage account generate-sas

@brettsam
Copy link
Member

Thanks @jtlz2. Glad you figured it out -- I agree we should be able to provide a better error string if we don't have a vaild connection string. I'm retitling this and moving it to the proper repo.

@brettsam brettsam changed the title Microsoft.Azure.WebJobs.Extensions.Storage: Object reference not set to an instance of an object. Throw meaningful error if AzureWebJobsStorage is not a proper connection string Jul 15, 2019
@brettsam brettsam transferred this issue from Azure/azure-functions-host Jul 15, 2019
@ghost ghost added the Needs: Triage 🔍 label Jul 15, 2019
@brettsam brettsam added this to the Triaged milestone Aug 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants