input: Write a Python function to process an EventGrid event, retrieve the corresponding entity from Azure Table Storage, and send an email notification using SendGrid.
  assert process_event(cosmosEvent) == "Email sent successfully"
  assert process_event(invalidEvent) == "Failed to retrieve entity"
  assert process_event(noEmailEvent) == "Failed to send email"
output: import os
  from azure.data.tables import TableServiceClient
  from azure.core.exceptions import ResourceNotFoundError
  from sendgrid import SendGridAPIClient
  from sendgrid.helpers.mail import Mail
  
  def process_event(event):
      try:
          # Set up connection to Azure Table Storage
          table_service_client = TableServiceClient.from_connection_string(os.getenv("AZURE_STORAGE_CONNECTION_STRING"))
          table_client = table_service_client.get_table_client(table_name=os.getenv("AZURE_TABLE_NAME"))
  
          # Extract partition key and row key from the event
          partition_key = event["partitionKey"]
          row_key = event["rowKey"]
  
          # Retrieve the entity from the table
          try:
              entity = table_client.get_entity(partition_key=partition_key, row_key=row_key)
          except ResourceNotFoundError:
              return "Failed to retrieve entity"
  
          # Extract email address from the entity
          email_address = entity.get("email")
          if not email_address:
              return "Failed to send email"
  
          # Create the SendGrid email message
          message = Mail(
              from_email=os.getenv("SENDGRID_FROM_EMAIL"),
              to_emails=email_address,
              subject="Notification",
              plain_text_content="This is a notification email."
          )
  
          # Send the email
          try:
              sg = SendGridAPIClient(os.getenv("SENDGRID_API_KEY"))
              response = sg.send(message)
              if response.status_code == 202:
                  return "Email sent successfully"
              else:
                  return "Failed to send email"
          except Exception:
              return "Failed to send email"
  
      except Exception as e:
          return "Failed to process event"