如何通过 TypeScript 将 EventhubNamespace TLS 版本设置为 1.2

问题描述 投票:0回答:0

我有一个要求将 eventhub 的 TLS 版本升级到 1.2。 事件中心是由打字稿创建的。 像这样:

EventhubNamespaceService.ts

import { EventHubManagementClient } from '@azure/arm-eventhub';
export default class EventhubNamespaceService {
  client: EventHubManagementClient;

  constructor(client: EventHubManagementClient) {
    this.client = client;
  }

  async createNamespace(
    resourcegroupName: string,
    name: string,
    maximumThroughputUnits: number = 5,
    isAutoInflateEnabled: boolean = true,
    location: string = 'westeurope',
  ): Promise<EventhubNamespace> {
    const resp = await this.client.namespaces.createOrUpdate(resourcegroupName, name, {
      maximumThroughputUnits,
      isAutoInflateEnabled,
      location,
    });

    return {
      id: resp.id!,
      name: resp.name!,
      isAutoInflateEnabled: resp.isAutoInflateEnabled,
      maximumThroughputUnits: resp.maximumThroughputUnits,
      resourceGroup: resourcegroupName,
    };
  }

EventhubService.ts

import { EventHubManagementClient } from '@azure/arm-eventhub';
import { AccessRights as AzureAccessRights } from '@azure/arm-eventhub/esm/models';

export default class EventhubService {
  client: EventHubManagementClient;

  constructor(client: EventHubManagementClient) {
    this.client = client;
  }

  async eventhub(
    resourcegroupName: string,
    namespaceName: string,
    name: string,
  ): Promise<Eventhub> {
    const resp = await this.client.eventHubs.get(resourcegroupName, namespaceName, name);

    return {
      name: resp.name!,
      id: resp.id!,
      resourcegroupName,
      namespaceName,
      partitionCount: resp.partitionCount!,
      messageRetentionInDays: resp.messageRetentionInDays!,
    };
  }

  async createOrUpdateEventhub(
    resourcegroupName: string,
    namespaceName: string,
    name: string,
    messageRetentionInDays: number = 1,
    partitionCount: number = 1,
    consumerGroups?: string[],
    authorizationRules?: AuthorizationRuleInput[],
  ): Promise<Eventhub> {
    const resp = await this.client.eventHubs.createOrUpdate(
      resourcegroupName,
      namespaceName,
      name,
      {
        messageRetentionInDays,
        partitionCount,
      },
    );

    if (consumerGroups) {
      await toPromiseChain(consumerGroups, (cg) =>
        this.client.consumerGroups.createOrUpdate(resourcegroupName, namespaceName, name, cg, {
          name: cg,
        }),
      );
    }

    if (authorizationRules) {
      await toPromiseChain(authorizationRules, (rule) =>
        this.client.eventHubs.createOrUpdateAuthorizationRule(
          resourcegroupName,
          namespaceName,
          name,
          rule.name,
          {
            rights: rule.rights.map((r) => AccessRights[r] as AzureAccessRights),
            name,
          },
        ),
      );
    }

    return {
      id: resp.id!,
      name: resp.name!,
      resourcegroupName,
      namespaceName,
      messageRetentionInDays: resp.messageRetentionInDays!,
      partitionCount: resp.partitionCount!,
    };
  }

我找不到任何地方可以添加与 TLS 版本相关的参数。但它会默认将 evenhubs 创建为 TLS v1.0。我不知道在哪里配置它。 我还搜索了微软学习网站。 https://learn.microsoft.com/en-us/javascript/api/@azure/arm-eventhub/namespaces?view=azure-node-latest

谁能告诉我如何配置将创建新事件中心的 TLS 版本作为 TLS 1.2 并将旧事件中心从 TLS 1.0 更新到 TLS 1.2.

谁能告诉我如何配置将创建新事件中心的 TLS 版本作为 TLS 1.2 并将旧事件中心从 TLS 1.0 更新到 TLS 1.2.

typescript azure namespaces tls1.2 azure-eventhub
© www.soinside.com 2019 - 2024. All rights reserved.