【问题标题】:Azure vault key using .Net 4.5使用 .Net 4.5 的 Azure 保管库密钥
【发布时间】:2021-04-08 08:52:29
【问题描述】:

我有一个 Azure 帐户,我需要使用 .NEt 4.5 类库来完成此操作

  • 创建 Key Vault 资源
  • 向 Key Vault 添加机密
  • 配置 Web 应用基础架构
  • 创建托管服务标识
  • 构建 ASP.NET Core Web 应用程序
  • 部署和验证 Web 应用程序

我找到的文章很少,但没有完整的文章或主要使用 asp.net Core。我需要使用 .Net 4.5 来创建它

您能提出解决方案吗?

【问题讨论】:

  • 您应该使用 Terraform/powershell/Azue Cli 处理所有这些 IaC。不适用于 .NET
  • @JuanmaFeliu 这是客户端使用 C# 执行此操作的要求
  • 好吧,废话对不起 :-) 告诉他们如何在 DevOps 中运行管道。

标签: c# asp.net azure


【解决方案1】:

我们可以使用 Microsoft.Azure.Management.Fluent 库来管理 Azure 资源 (https://www.nuget.org/packages/Microsoft.Azure.Management.Fluent/)

结合每个资源(KeyVault、WebApp 和任何其他资源)的 ARM 模板,我们可以通过为每个模板调用 Fluent 库来创建资源

下面提供使用 Fluent 库创建存储帐户的示例代码

string tenantId = "";
string clientId = "";
string clientSecret = "";
var credentials = SdkContext.AzureCredentialsFactory.FromServicePrincipal(clientId, clientSecret, tenantId, AzureEnvironment.AzureGlobalCloud);
var azure = Azure.Configure().WithLogLevel(Microsoft.Azure.Management.ResourceManager.Fluent.Core.HttpLoggingDelegatingHandler.Level.Basic).Authenticate(credentials).WithSubscription("<<subscriptionid>>");

var templateString = File.ReadAllText("storageaccountARMTemplate.json");
var resourceName = "storageaccounttemplate";
var resourceGroupName = "rglearnazure";
            azure.Deployments.Define(resourceName).WithExistingResourceGroup(resourceGroupName).WithTemplate(templateString).WithParameters("{}").WithMode(DeploymentMode.Incremental).Create();

【讨论】:

    猜你喜欢
    • 2016-10-13
    • 2021-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-14
    • 2020-04-04
    • 2020-10-19
    相关资源
    最近更新 更多