I have this following code to generate random data of 1 billion rows for my task, but it fails, with stack message below:
Result: Failure Exception: ModuleNotFoundError: No module named 'azure.storage'. Please check the requirements.txt file for the missing module. For more info, please refer the troubleshooting guide: https://aka.ms/functions-modulenotfound Stack: File "/azure-functions-host/workers/python/3.10/LINUX/X64/azure_functions_worker/dispatcher.py", line 380, in _handle__function_load_request func = loader.load_function( File "/azure-functions-host/workers/python/3.10/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 48, in call raise extend_exception_message(e, message) File "/azure-functions-host/workers/python/3.10/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 44, in call return func(*args, **kwargs) File "/azure-functions-host/workers/python/3.10/LINUX/X64/azure_functions_worker/loader.py", line 132, in load_function mod = importlib.import_module(fullmodname) File "/usr/local/lib/python3.10/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/home/site/wwwroot/HttpTrigger1/init.py", line 29, in <module> from azure.storage.blob import BlobService
import logging
import azure.functions as func
def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
name = req.params.get('name')
if not name:
try:
req_body = req.get_json()
except ValueError:
pass
else:
name = req_body.get('name')
if name:
return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.")
else:
return func.HttpResponse(
"This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
status_code=200
)
import csv
import random
import string
from azure.storage.blob import BlobService
def generate_random_string(length):
letters = string.ascii_letters
return ''.join(random.choice(letters) for _ in range(length))
def generate_mock_data(num_rows):
# Generate mock sales data
rows = []
for i in range(num_rows):
sale_id = i + 1
sale_amount = random.uniform(10, 1000)
customer_name = generate_random_string(10)
customer_email = generate_random_string(5) + '@example.com'
customer_address = generate_random_string(20)
vendor_name = generate_random_string(10)
vendor_email = generate_random_string(5) + '@example.com'
vendor_address = generate_random_string(20)
rows.append([sale_id, sale_amount, customer_name, customer_email, customer_address, vendor_name, vendor_email, vendor_address])
# Save mock sales data as CSV file
csv_file_path = 'mock_sales_data.csv'
with open(csv_file_path, 'w', newline='') as csvfile:
writer = csv.writer(csvfile)
writer.writerow(['Sale ID', 'Sale Amount', 'Customer Name', 'Customer Email', 'Customer Address', 'Vendor Name', 'Vendor Email', 'Vendor Address'])
writer.writerows(rows)
# Upload the CSV file to Azure Blob Storage
connection_string = "<my connection string for my blob>"
container_name = "dfgfdgfdd"
blob_service_client = BlobServiceClient.from_connection_string(connection_string)
container_client = blob_service_client.get_container_client(container_name)
blob_client = container_client.get_blob_client(csv_file_path)
with open(csv_file_path, "rb") as data:
blob_client.upload_blob(data)
# Specify the number of rows you want (1 billion in this case)
num_rows = 1000000000
# Generate the mock data and upload to Azure Blob Storage
generate_mock_data(num_rows)