Define a component

    When building an app, you most likely would create your own component file definitions depending on the building block and specific component that you’d like to use.

    As an example of how to define custom components for your application, you will now create a component definition file to interact with the secrets building block.

    In this guide you will:

    • Create a local JSON secret store
    • Register the secret store with Dapr using a component definition file
    • Obtain the secret using the Dapr HTTP API

    While Dapr supports , the easiest way to get started is a local JSON file with your secret (note this secret store is meant for development purposes and is not recommended for production use cases as it is not secured).

    Create a new directory named my-components to hold the new component file:

      Inside this directory create a new file localSecretStore.yaml with the following contents:

      You can see that the above file definition has a which tells Dapr to use the local file component as a secret store. The metadata fields provide component specific information needed to work with this component (in this case, the path to the secret store JSON is relative to where you call dapr run from.)

      Run the following command to launch a Dapr sidecar that will listen on port 3500 for a blank application named myapp:

      In a separate terminal run:

        You should see output with the secret you stored in the JSON file.

        Next step: Explore Dapr quickstarts >>

        Last modified November 12, 2021 :