Skip to content

Latest commit

 

History

History

Bet.Extensions.Emet.Azure.Storage

Bet.Extensions.Emet.Azure.Storage

GitHub license Build status NuGet Nuget feedz.io

The second letter in the Hebrew alphabet is the ב bet/beit. Its meaning is "house". In the ancient pictographic Hebrew it was a symbol resembling a tent on a landscape.

Emet stands for truth in Hebrew.

Note: Pre-release packages are distributed via feedz.io.

Summary

The storage provider for Azure Storage Blob for RulesEngine library.

buymeacoffee

Give a Star! ⭐

If you like or are using this project to learn or start your solution, please give it a star. Thanks!

Install

    dotnet add package Bet.Extensions.Emet.Azure.Storage

Usage

The default authentication method for Azure Storage Blob is token. In order to make it work on local machine please make sure the following steps are completed:

  1. Azure CLI installed and you are login with Azure Account that have Storage Blob Data Contributor associated with your development account.

  2. dotnet new tool-manifest and install AppAuthentication - dotnet tool install appauthentication

  3. Run in the command prompt appauthentication run --local --verbose:debug in the root of your project. Make sure that Visual Studio or VSCode is restarted.

{
  "profiles": {
    "Bet.Extensions.Emet.Workersample": {
      "commandName": "Project",
      "environmentVariables": {
        "DOTNET_ENVIRONMENT": "Development",
        "MSI_ENDPOINT": "http://localhost:5050/oauth2/token",
        "MSI_SECRET": "38597b24-96c9-4b5a-b5c5-405469523460"
      },
      "dotnetRunMessages": "true"
    },
    "Docker": {
      "commandName": "Docker"
    }
  }
}
  1. Add Workflow to Storage Blob -> Container workflow
[
  {
    "WorkflowName": "RetirementEligibilityWorkflow",
    "Rules": [
      {
        "RuleName": "IsEligible",
        "SuccessEvent": "",
        "ErrorMessage": "Employee is not eligible.",
        "ErrorType": "Error",
        "RuleExpressionType": "LambdaExpression",
        "Expression": "input1.LengthOfServiceInDays >= 190 OR input1.IsOverridden == true"
      }
    ]
  }
]
  1. Add the DI Registration
public static IServiceCollection AddRetirementEligibilityWorkflow(this IServiceCollection services)
{
    services.AddTransient<IRetirementService>(
            sp =>
            {
                var providers = sp.GetServices<IEmetProvider>().ToList();
                var provider = providers.FirstOrDefault(x => x.Name ==  Workflows.AzureRetirementEligibilityWorkflow);
                if (provider == null)
                {
                    throw new ArgumentNullException( Workflows.AzureRetirementEligibilityWorkflow, $"IEmetProvider wasn't register");
                }

                return new RetirementService(provider);
            });

    var builder = services.AddEmetProvider( Workflows.AzureRetirementEligibilityWorkflow).AddAzureStorageLoader(
            workflowName,
            configOptions: (options, config) =>
            {
                options.BlobServiceUri = new Uri(config["SharedBlobServiceUri"]);
            });
    return services;
}
  1. appsetting.json
  "SharedBlobServiceUri": "https://betstorage.blob.core.windows.net/",

  "AzureCountryWorkflow": {
    "BlobServiceUri": "",
    "ContainerName": "workflows",
    "FileNames": [
        "CountryWorkflow.json"
    ]
  },

  "AzureRetirementEligibilityWorkflow": {
    "BlobServiceUri": "",
    "ContainerName": "workflows",
    "FileNames": [
        "RetirementEligibilityWorkflow.json"
    ]
  },

  "AzureDiscountWorkflow": {
    "BlobServiceUri": "",
    "ContainerName": "workflows",
    "FileNames": [
        "DiscountWorkflow.json"
    ]
  },

References