Replace user content in Logic App workflows with the Regex Translator
At the time of writing, there is no built-in Logic App functionality available to run regular expression replacements without using inline code. The Invictus Regex Translation Framework component fills this missing link. It provides a HTTP-endpoint to run regular expression replacements. All available translations are available in an Azure Table Storage.
Regex translate user content
The Regex Translation component has a single endpoint available: /api/RegexTranslation. Given an user content and matched stored (Azure Table Storage, default: RegexTranslator table) regex translation, the endpoint responds with the translated content.
| JSON property | Required | Description |
|---|---|---|
Content | yes | User content that should translated. |
MatchKey | yes | Set of 'keys' that translates to Azure Table Storage partition keys. |
Full request example
// POST /api/RegexTranslation
{
"Content": "The provided host name 'website.com' could not be resolved",
"MatchKey": ["OrderService", "InvoiceService"]
}
Full response example
// Found stored translation:
// 200 OK <- /api/RegexTranslation
{
"Content": "System could not reach endpoint 'website.com' as it is not available, please contact John to follow-up.",
"IsTranslated": true,
"RowKey": "2f71ec69-1fff-4b80-9ae1-947a58e4a039"
}
// Did not found stored translation:
// 200 OK <- /api/RegexTranslation
{
"Content": "The provided host name 'website.com' could not be resolved",
"IsTranslated": false,
"RowKey": ""
}
Stored regex translations
Store available Regex translations in the Azure Table Storage table called RegexTranslator (Invictus creates this table automatically). Each stored entity should have following custom properties:
| Custom entity property name | Description |
|---|---|
MatchPattern | The regular expression to match the incoming user Content. It uses named groups to cut certain information from the content. |
OutputPattern | The outgoing text, containing possible {group-name} occurrences to paste the subtracted information. |
Full translation example
| Entity property name | Value |
|---|---|
RowKey | 2f71ec69-1fff-4b80-9ae1-947a58e4a039 |
PartitionKey | OrderService |
MatchPattern | "The provided host name '(?<url>[^]*)' could not be resolved." |
OutputPattern | "System could not reach endpoint '{url}' as it is not available, please contact John to follow-up." |
- Many pastes: the component pastes the subtracted information from named groups more than once.
- Single match: the user
Contentcan only match a single stored translation - the component picks the first match. - No pastes: the
OutputPatterndoesn't necessarily have to contain{group-name}occurrences, it can only contain text.
Related Bicep template parameters
| Name | Description | Tags |
|---|---|---|
invictusRegexTranslatorFunctionLocalContainerImage | The URL that navigates to the Azure Container App image of the Regex Translator component. | comp:regex-translatorcontainer-apps |
regexTranslatorFunctionNamedefault: inv-${resourcePrefix}-regextranslator | The name of the Azure Container App deployed for the Regex Translator component. | comp:regex-translatorcontainer-apps |
regexTranslatorScaling | The Azure Container App scaling options of the Regex Translator component. | comp:regex-translatorscalingcontainer-apps |
storageAccountNamedefault: invictus${resourcePrefix}store | The name of the shared Azure Storage Account, used by all Framework components. | comp:pubsubcomp:transcocomp:regex-translatorcomp:xsd-validatorcomp:xml-json-convertercomp:time-sequencercomp:sequence-controllerstorage |