定义一个组件
当构建一个应用程序时,你很可能会根据你想使用的构建块和特定的组件来定义自己的组建文件。
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.
在本指南中,您将:
- 创建本地JSON密钥存储
- 使用组件定义文件在 Dapr 注册密钥存储
- 使用 Dapr HTTP API 获取密钥
首先保存下面的 JSON 内容到一个名为 的文件:
创建一个名为 my-components
的目录来存放新的组件文件:
在此目录内创建一个新文件 localSecretStore.yaml
,内容如下:
运行以下命令以启动 Dapr sidecar,它将在端口 3500 上监听名为 myapp 的空白应用程序:
dapr run --app-id myapp --dapr-http-port 3500 --components-path ./my-components
在单独的终端运行中:
你看到的输出应该为你存储在JSON文件中的密钥