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
});
withKind
Sets the kind of the SignalR instance.
signalRBuilder.withKind('SignalR');
withSku
Sets the SKU for the SignalR instance.
signalRBuilder.withSku({ name: 'Standard_S1', tier: 'Standard' });
withPrivateLink
Sets the private link properties for the SignalR instance.
signalRBuilder.withPrivateLink({
// PrivateLinkPropsType properties
});
allowsOrigins
Sets the allowed origins for CORS.
signalRBuilder.allowsOrigins('https://example.com', 'https://another.com');
withOptions
Sets additional options for the SignalR instance.
signalRBuilder.withOptions({
disableAadAuth: true,
disableLocalAuth: false,
publicNetworkAccess: true,
clientCertEnabled: false,
});
buildSignalR
Creates the SignalR instance with the specified configurations.
This method is called internally by the build
method and is not typically called directly.
buildPrivateLink
Configures the private link for the SignalR instance.
This method is called internally by the build
method and is not typically called directly.
buildSecrets
Stores SignalR connection details in Azure Key Vault.
This method is called internally by the build
method and is not typically called directly.
build
Builds 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.