azure 如何将EventhubNamespace TLS版本设置为1,2通过TypeScript

pobjuy32  于 2023-05-01  发布在  TypeScript
关注(0)|答案(1)|浏览(93)

我需要将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作为默认值。我不知道在哪里配置它。我还搜索了Microsoft learn website
如何配置将创建新事件中心的TLS版本为TLS 1。2并从TLS 1更新旧的事件中心。0到TLS 1.2?

hc8w905p

hc8w905p1#

请您利用EventHub的minimumTlsVersion属性并检查是否有帮助?
此属性指定群集支持的最低TLS版本。可接受值为:1.0 1.1 12.
更多信息在这里和这里。

相关问题