SignalRBuilder Class OverviewThe SignalRBuilder class is designed to build and configure an Azure SignalR instance with specific configurations such as kind, SKU, private link, allowed origins, and other options.
Initializes the SignalRBuilder with the provided arguments and sets the instance name.
const signalRBuilder = new SignalRBuilder({
name: 'mySignalR',
group: { resourceGroupName: 'myResourceGroup' },
// other necessary arguments
});
withKindSets the kind of the SignalR instance.
signalRBuilder.withKind('SignalR');
withSkuSets the SKU for the SignalR instance.
signalRBuilder.withSku({ name: 'Standard_S1', tier: 'Standard' });
withPrivateLinkSets the private link properties for the SignalR instance.
signalRBuilder.withPrivateLink({
// PrivateLinkPropsType properties
});
allowsOriginsSets the allowed origins for CORS.
signalRBuilder.allowsOrigins('https://example.com', 'https://another.com');
withOptionsSets additional options for the SignalR instance.
signalRBuilder.withOptions({
disableAadAuth: true,
disableLocalAuth: false,
publicNetworkAccess: true,
clientCertEnabled: false,
});
buildSignalRCreates the SignalR instance with the specified configurations.
This method is called internally by the build method and is not typically called directly.
buildPrivateLinkConfigures the private link for the SignalR instance.
This method is called internally by the build method and is not typically called directly.
buildSecretsStores SignalR connection details in Azure Key Vault.
This method is called internally by the build method and is not typically called directly.
buildBuilds the SignalR instance, configures private link, and stores secrets.
const resourceInfo = signalRBuilder.build();
console.log(resourceInfo);
Here is a full example demonstrating how to use the SignalRBuilder class:
import SignalRBuilder from './Builder/SignalRBuilder';
import { SignalRBuilderArgs } from './types';
const args: SignalRBuilderArgs = {
name: 'mySignalR',
group: { resourceGroupName: 'myResourceGroup' },
// other necessary arguments
};
const signalRBuilder = new SignalRBuilder(args);
signalRBuilder
.withKind('SignalR')
.withSku({ name: 'Standard_S1', tier: 'Standard' })
.withPrivateLink({
// PrivateLinkPropsType properties
})
.allowsOrigins('https://example.com', 'https://another.com')
.withOptions({
disableAadAuth: true,
disableLocalAuth: false,
publicNetworkAccess: true,
clientCertEnabled: false,
});
const resourceInfo = signalRBuilder.build();
console.log(resourceInfo);
This guideline should help developers understand and reuse the methods in the SignalRBuilder class effectively.