AzureFunctionsPGPEncrypt icon indicating copy to clipboard operation
AzureFunctionsPGPEncrypt copied to clipboard

Example or advice how to use the repo

Open HerdMS opened this issue 2 years ago • 2 comments

Hi, i am trying to use this repo for a Blob Trigger Azure Function. When a ne blob is detected, it should take that blob, encrypt it and store it in the same Blob Container but different Subfolder.

I stored the public Key in Key Vault. First I took the .asc file and used pwoershell to convert it to Base64 .txt file. Then i copied the content of the .txt file and stored it in a secret, named it pgp-public-key.

Thats where i am now. I dont understand what to do next, how to store the key in an environmental variable? On my local system? But i thaught it will take the secret from key vault? This is my first C# project, i started this week and have no clue what to do. Maybe someone can help/give advice?

Best regards, Frederik

HerdMS avatar Dec 12 '23 15:12 HerdMS

Hi!

If you are deploying the function to Azure, you can reference the key in your Key Vault by creating an application setting with this syntax: @Microsoft.KeyVault(VaultName=myvault;SecretName=mysecret)

The function app needs to have access rights to the Key Vault for this to work.

You can also add the public key directly as an application setting and skip using Key Vault.

Application settings are exposed as environmental variables when the function is running.

When running locally, you can add the setting in a local.settings.json file instead inside the Values object and that will also be exposed as an environment variable. The file should look like this and be added in the AzureFunctionsPGPEncrypt project:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "pgp-public-key": ""
  }
}

lfalck avatar Dec 12 '23 16:12 lfalck

Hi @lfalck, thanks for the explanations. I figured it out to get the key from Key Vault!

HerdMS avatar Dec 13 '23 09:12 HerdMS