Search code examples
pythonazureazure-storageazure-storage-emulator

NameError: global name 'DEV_ACCOUNT_NAME' is not defined - Azure Storage Emulator


I'm trying to use the Azure Storage Emulator in my python app but getting the following error:

from azure.storage.table import TableService, Entity

#Added after error
global DEV_ACCOUNT_NAME
DEV_ACCOUNT_NAME = "devstoreaccount1"

table_service = TableService(account_name='devstoreaccount1', account_key='Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==',)

table_service.use_local_storage = True
table_service.is_emulated = True

table_service.create_table("test")

Error:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensio
ns\Microsoft\Python Tools for Visual Studio\2.0\visualstudio_py_util.py", line 7
6, in exec_file
    exec(code_obj, global_variables)
  File "c:\ScratchApp\ScratchApp.py", line 17, in <module>
    table_service.create_table("test")
  File "C:\Python27\lib\site-packages\azure\storage\table\tableservice.py", line
 274, in create_table
    request, self.use_local_storage)
  File "C:\Python27\lib\site-packages\azure\storage\_common_serialization.py", l
ine 212, in _update_request_uri_query_local_storage
    return '/' + DEV_ACCOUNT_NAME + uri, query
NameError: global name 'DEV_ACCOUNT_NAME' is not defined
Press any key to continue . . .

Any ideas?


Solution

  • Declaring a variable as global in one module won't magically make it visible to other modules.

    To address your specific problem, though, it looks like this may be a known issue that was fixed some time ago. Do you have an up-to-date version of the azure storage module?