简体   繁体   English

如何在 Angular 中使用 Azure 应用程序配置

[英]how to use Azure App Configuration in Angular

Is it possible to use Azure App config in Angular application?是否可以在 Angular 应用程序中使用 Azure 应用程序配置? goal is to define Secrets and other strings in Azure App Config目标是在Azure App Config中定义 Secrets 和其他字符串

and use it in Angular application.并在 Angular 应用程序中使用它。

All the examples out there are for.Net所有的例子都是for.Net

There is a npm package available for Azure App Confrig: https://www.npmjs.com/package/@azure/app-configuration There is a npm package available for Azure App Confrig: https://www.npmjs.com/package/@azure/app-configuration

Essentially, your code would have something like this:本质上,您的代码将具有以下内容:

const client = new AppConfigurationClient("<connection string>");

const setting = await client.getConfigurationSetting({
  key: "hello"
});

console.log("Retrieved value:", setting.value);

I would encourage you to strongly consider connecting to App Config on the server-side instead of client-side.我鼓励您强烈考虑在服务器端而不是客户端连接到 App Config。 Once you use a client-side the connection string for your App Config instance is essentially public for anyone to access, including values that you didn't intend them to have.一旦您使用客户端,您的 App Config 实例的连接字符串本质上是公开的,任何人都可以访问,包括您不希望他们拥有的值。 It also allows them to make as many requests as they want until you rotate the keys, possibly inflating your Azure bill.它还允许他们根据需要提出任意数量的请求,直到您轮换密钥,这可能会增加您的 Azure 账单。 If you've considered these issues and decided the risk is worth it, then the npm package and the examples in its docs should get you on the right path.如果您已经考虑过这些问题并认为风险是值得的,那么 npm package 及其文档中的示例应该会让您走上正确的道路。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM