Skip to content

Instantly share code, notes, and snippets.

View MahdiKarimipour's full-sized avatar
🎯
Focusing

MK MahdiKarimipour

🎯
Focusing
  • TechnologyLeads
  • Sydney, Australia
View GitHub Profile
@MahdiKarimipour
MahdiKarimipour / performance-improvement-spin-up-entity-framework.cs
Created October 28, 2021 06:10
Enable Caching of Internal Service Providers in Production
services.AddDbContextPool<IdentityDBContext>(options =>
{
options.UseSqlServer(secrets.DbConnectionString,
x => x.MigrationsAssembly("DataAccess")
.EnableRetryOnFailure(maxRetryCount: 3))
.UseLazyLoadingProxies()
.EnableSensitiveDataLogging(CurrentEnvironment.IsDevelopment())
.EnableServiceProviderCaching()
.UseLoggerFactory(IdentityDBContext.PropertyAppLoggerFactory);
});
@MahdiKarimipour
MahdiKarimipour / event-driven-architecture-base-hosted-task.cs
Created October 21, 2021 19:54
Base HostedService for Long Running Tasks
public abstract class MyBackgroundService : IHostedService, IDisposable
{
private Task executingTask;
private readonly CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
protected abstract Task ExecuteAsync(CancellationToken stoppingToken);
public virtual Task StartAsync(CancellationToken cancellationToken)
{
executingTask = ExecuteAsync(cancellationTokenSource.Token);
public class KafkaHostedService : MyBackgroundService
{
private readonly ILogger<KafkaHostedService> logger;
private readonly AppSettings appSettings;
private readonly IConfiguration configuration;
private readonly IServiceScopeFactory scopeFactory;
public KafkaHostedService(
ILogger<KafkaHostedService> logger,
AppSettings appSettings,
@MahdiKarimipour
MahdiKarimipour / event-driven-architecture-inject-service.cs
Created October 21, 2021 11:35
Kafka Service Injection for Event Driven Architecture
services.AddTransient<IKafkaService>(x =>
new KafkaService(
appSettings.KafkaSettings.Server,
appSecrets.KafkaSaslKey,
appSecrets.KafkaSaslSecret));
public class KafkaService : IKafkaService
{
private readonly string saslUsername;
private readonly string saslPassword;
public readonly string serverAddress;
public KafkaService(string serverAddress, string saslUsername, string saslPassword)
{
this.serverAddress = serverAddress;
this.saslUsername = saslUsername;
@MahdiKarimipour
MahdiKarimipour / pellerex-identity-api-refresh-token-response.json
Created October 13, 2021 06:14
Pellerex Identity Response Refresh Token Response
{
"user": {
"accessToken": "eyJhbGciOiJodH.....PXKnzQbFZ9xkNx0",
"refreshToken": "CfDJ8HmkbyESYkdH......ajwoA=="
}
}
@MahdiKarimipour
MahdiKarimipour / pellerex-identity-refresh-token-request.json
Created October 13, 2021 06:11
Pellerex Identity API Refresh Token Refresh
{
"AccessToken": "eyJhbGciOiJs.....Brev24Z1n80",
"RefreshToken": "CfDJ8H...TTwyjZEPpw=="
}
@MahdiKarimipour
MahdiKarimipour / pellerex-identity-api-login-response.json
Last active March 26, 2024 02:24
SignIn Response for Pellerex Identity API
{
"user": {
"userId": "a3686...8b37",
"tenantId": "37fd7...940",
"tenantDomain": "https://app.contoso-finance.com",
"accessToken": "eyJhbIzNyIsIlRlbmF....pMqI4KUZ1w",
"refreshToken": "kcGqqnGLOfJpG....h1M06Vo=",
"email": "[email protected]",
"isSociallyAuthenticated": false,
"embeddedModeAuthentication": false
@MahdiKarimipour
MahdiKarimipour / kubernetes-cd-pipeline-script.yaml
Created September 28, 2021 11:27
CD Pipeline for Kubernetes Cluster
az account set --subscription subscription-id
az aks get-credentials --resource-group TechnologyLeads-Common --name technologyleads-aks
kubectl apply -f SecretProviderClass.yaml
helm uninstall ecosystem-identity-api-release
helm upgrade --install ecosystem-identity-api-release ./Helm --values ./Helm/values.production.yaml --set image.tag="v1.0.0" --set global.env.ASPNETCORE_ENVIRONMENT="Production"
@MahdiKarimipour
MahdiKarimipour / kubernetes-ci-pipeline-copy-helm-charts.yaml
Created September 28, 2021 11:24
Copy Helm Charts from CI Pipeline to CD
- task: CopyFiles@2
inputs:
SourceFolder: 'Infrastructure'
Contents: '**'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: '$(projectName)'