I'm trying to use the Azure Storage Emulator in the following scenario:
- Blob uploaded to Emulated container
- Emulated Event Grid message created when blob uploaded
- Emulated Queue Storage receives Event Grid message
- Locally running Azure Function is triggered from Queue Storage message
Issue:
1 above. Works fine (emulator is up and running)
2 above. Is manual, I don't want to download and use a third party Event Grid emulator.
- Instead I create the Event Grid message manually with the name of the uploaded blob
{
"id": "<long-guid>",
"data": {
"api": "FlushWithClose",
"clientRequestId": "<long-guid>",
"requestId": "<long-guid>",
"eTag": "0x8D9430B96888008",
"contentType": "application/octet-stream",
"contentLength": 4633473584,
"contentOffset": 0,
"blobType": "BlockBlob",
"blobUrl": "http://127.0.0.1:10000/devstoreaccount1/test/710520200429.csv",
"url": "http://127.0.0.1:10000/devstoreaccount1/test/710520200429.csv",
"sequencer": "0000000000000000000000000000933600000000000023c7",
"identity": "<long-guid>",
"storageDiagnostics": {
"batchId": "<long-guid>"
}
},
"topic": "/subscriptions/<long-guid>/resourceGroups/DEV/providers/Microsoft.Storage/storageAccounts/fa00001dev",
"subject": "/blobServices/default/containers/test/blobs/710520200429.csv",
"event_type": "Microsoft.Storage.BlobCreated"
}
- Then create a new message in the Emulator Queue Storage and paste it in (basically 3. above)
4 above. The Function triggers but is unable to execute the following piece of code:
credentials = DefaultAzureCredential()
def create_blob_client(credentials):
try:
blob_client = BlobClient.from_blob_url(eg_msg_json['data']['blobUrl'], credentials, max_single_get_size = 256*1024*1024, max_chunk_get_size = 128*1024*1024)
logging.info(f'####### Successfully created BlobClient #######')
except:
logging.error(f'####### Failed to create BlobClient #######')
logging.error(f'####### Blob URL: {eg_msg_json["data"]["blobUrl"]} #######')
return blob_client
- Because the
blobUrlofhttp://127.0.0.1:10000/devstoreaccount1/test/710520200429.csveither isn't correct or theBlobClient.from_blob_urldoesn't allow aBlobClientto be created from the emulator.
Error:
[2021-07-31T00:23:01.397Z] ManagedIdentityCredential will use IMDS
[2021-07-31T00:23:01.405Z] Executed 'Functions.fa00003' (Failed, Id=55f8ce9e-08b5-41e2-bd61-d753da0d72e1, Duration=47ms)
[2021-07-31T00:23:01.410Z] System.Private.CoreLib: Exception while executing function: Functions.fa00003. System.Private.CoreLib: Result: Failure
Exception: ValueError: Invalid tenant id provided. You can locate your tenant id by following the instructions here: https://learn.microsoft.com/partner-center/find-ids-and-domain-names
Stack: File "C:\Users\test\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\3.8\WINDOWS\X64\azure_functions_worker\dispatcher.py", line 398, in _handle__invocation_request
call_result = await self._loop.run_in_executor(
File "C:\Users\test\AppData\Local\Programs\Python\Python38\lib\concurrent\futures\thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "C:\Users\test\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\3.8\WINDOWS\X64\azure_functions_worker\dispatcher.py", line 602, in _run_sync_func
return ExtensionManager.get_sync_invocation_wrapper(context,
File "C:\Users\test\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\3.8\WINDOWS\X64\azure_functions_worker\extension.py", line 215, in _raw_invocation_wrapper result = function(**args)
File "C:\Users\test\Desktop\git\Azure\Functions\fa00003\fa00003\__init__.py", line 132, in main
credentials = DefaultAzureCredential()
File "C:\Users\test\Desktop\git\Azure\Functions\fa00003\.venv\lib\site-packages\azure\identity\_credentials\default.py", line 123, in __init__
credentials.append(VisualStudioCodeCredential(tenant_id=vscode_tenant_id))
File "C:\Users\test\Desktop\git\Azure\Functions\fa00003\.venv\lib\site-packages\azure\identity\_credentials\vscode.py", line 43, in __init__
validate_tenant_id(self._tenant_id)
File "C:\Users\test\Desktop\git\Azure\Functions\fa00003\.venv\lib\site-packages\azure\identity\_internal\__init__.py", line 40, in validate_tenant_id
raise ValueError(
.
Can anyone tell me which is correct here?