Giter VIP home page Giter VIP logo

azure-functions-keyvault-binding's Introduction

Build status

An Azure Functions (2.0) binding for KeyVault

  1. Create a new Azure Function instance in Azure

  2. Create a new KeyVault instance in Azure

  3. Ensure the Azure Function has 'Managed Service Identity' turned on

  4. Add the Azure Function (by resource name) to the Key Vault's Access Policy list with 'Secret | Get' permissions Fill out only the 'Select Principal' part, not the 'Authorized application' part of the form

    You can get more detail on setting this up by reading this blog post from Functions PM, Jeff Hollan.

  5. Use the KeyVault binding in your Azure Function by:

Adding the nuget package to your project

Install-Package BC3Technologies.Azure.Functions.Extensions.KeyVault -IncludePrerelease

Then referencing it in your Function definition

public static IActionResult Run([HttpTrigger(AuthorizationLevel.Function, "get", Route = null)]HttpRequest req, [KeyVaultSecret(@"MyKv", @"MySecretId")]string secretValue, ILogger log)

where MyKv and MySecretId are defined in your app settings like:

"MyKv": "kv23958612",
"MySecretId": "fooSecret"
  1. Run your function & you will see the secretValue parameter populated with the value from the MyKv Key Vault for the secret MySecretId
  • You can also use [KeyVaultSecret(@"MyKv", @"MySecretId")]**out** string myNewKeyValue to set the value of fooSecret in KeyVault
  • You can get a JsonWebKey for a Key Vault key by using [KeyVaultKey("kvresourcesetting","keynamesetting")]JsonWebKey myKey

azure-functions-keyvault-binding's People

Contributors

brandonh-msft avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.