Skip to content

.NET function that is triggered when a blob is updated on Azure blob storage and parse the changes to the CosmosDB used to present the my experience information on my OnlineCV project.

Notifications You must be signed in to change notification settings

franciscosuca/dataHandler

Repository files navigation

Cloud Setup

Setup CosmosDB for RBAC authentication

Instead of relying on the connection strings for using or testing your application, it is better to use the tokenCredential generated by the instance DefaultAzureCredential. Follow the next steps to achieve the registration of your user on the CosmosDB.

  1. Get the unique identifier of the role definition in the id property.

az cosmosdb sql role definition list --resource-group "<name-of-existing-resource-group>" --account-name "<name-of-existing-nosql-account>"

  1. Get the unique identifier for your current account.

az cosmosdb show --resource-group "<name-of-existing-resource-group>" --name "<name-of-existing-nosql-account>" --query "{id:id}"

  1. Create the role in AZ for

az cosmosdb sql role assignment create -g "<resource_group>" -a "db_account" -d "val_from_step1" --principal-id "your_Entra_id" --scope "val_from_step2"

  1. Verfiy assignment az cosmosdb sql role assignment list -g "resource_group" -a "db_account"

Note: for more information visit MS Learn.

Setup Local Environment

Running Blob Containers locally

Azurite

This will help you to run an emulator of a blob storage locally in your PC.

azurite --silent --location azurite --debug azurite/debug.log

Setup Project

  1. Setup the local environment to work with Azurite by adding the following parameters to the local.settings.json file:
{
  "Values": {
    "AzureWebJobsSecretStorageType": "Files",
    "f6bc32_STORAGE": "UseDevelopmentStorage=true",
    "AzureWebJobsStorage": "UseDevelopmentStorage=true"
  }
}

NOTE: Look at the file named example.local.settings.json for more details.

Each parameter serves a specific purpose:

  • AzureWebJobsSecretStorageType: "Files" tells Azure Functions to store secrets in the local filesystem instead of Azure Key Vault
  • f6bc32_STORAGE: This is the connection string used by your contentTrigger function to connect to the blob storage. It's referenced in your code via the Connection property in the contentTrigger attribute
  • AzureWebJobsStorage: This is a required setting for Azure Functions runtime. It's used for managing function execution state, storing logs, and coordinating function execution

Run the function

1. Method CLI: Run the command below

func start --dotnet-isolated

2. Method UI: Run the process below

  • Press Ctrl+Shift+P
  • Type "Tasks: Run Task"
  • Select "func: host start"

Azure Data Explorer

  1. With this tool you will be able to manage the containers used for your local test.
  1. Create local blob-container. Name it after the string text on the first argument of "contentTrigger", i.e., samples-workitems.

Learn more about blob-storage functions at Microsoft Learn

Foot Note

  • Version of Newtonsoft to avoid: versions before 13.0.1

About

.NET function that is triggered when a blob is updated on Azure blob storage and parse the changes to the CosmosDB used to present the my experience information on my OnlineCV project.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages