-
Notifications
You must be signed in to change notification settings - Fork 315
Closed
Description
What happened?
There is no way to add caching through the CLI.
If we compare how we add telemetry:
dab add-telemetry
--app-insights-enabled true
--app-insights-conn-string "@env('app-insights-connection-string')"{
"runtime": {
"telemetry": {
"application-insights": {
"enabled": true,
"connection-string": "@env('app-insights-connection-string')"
}
}
}
}
add-telemetryalso works to update telemetry
There is no comparable for caching.
We need two commands, one for runtime the other for entity.
dab add-caching --enabled true --ttl-seconds 10dab update Actor --caching.enabled true --caching.ttl-seconds 10assuming my entity name is "Actor"
The only way to edit from the command line today is, for example, using PowerShell.
function Add-Caching-Runtime {
param (
[PSCustomObject]$jsonContent,
[bool]$enabled,
[int]$ttl
)
if (-not $jsonContent.runtime) {
throw "Runtime section is missing in the configuration file."
}
if (-not $jsonContent.runtime.cache) {
$jsonContent.runtime | Add-Member -MemberType NoteProperty -Name cache -Value @{ enabled = $enabled; "ttl-seconds" = $ttl }
} else {
$jsonContent.runtime.cache.enabled = $enabled
$jsonContent.runtime.cache."ttl-seconds" = $ttl
}
return $jsonContent
}
function Add-Caching-Entity {
param (
[PSCustomObject]$jsonContent,
[string]$entityName,
[bool]$enabled,
[int]$ttl
)
if (-not $jsonContent.entities.$entityName) {
throw "Entity '$entityName' is missing in the configuration file."
}
if (-not $jsonContent.entities.$entityName.cache) {
$jsonContent.entities.$entityName | Add-Member -MemberType NoteProperty -Name cache -Value @{ enabled = $enabled; "ttl-seconds" = $ttl }
} else {
$jsonContent.entities.$entityName.cache.enabled = $enabled
$jsonContent.entities.$entityName.cache."ttl-seconds" = $ttl
}
return $jsonContent
}
# Example usage inline
$configFilePath = "dab-config.json"
$jsonContent = Get-Content $configFilePath -Raw | ConvertFrom-Json
$jsonContent = Add-Caching-Runtime -jsonContent $jsonContent -enabled $true -ttl 60
$jsonContent = Add-Caching-Entity -jsonContent $jsonContent -entityName "Actor" -enabled $true -ttl 60
$jsonContent | ConvertTo-Json -Depth 10 | Set-Content $configFilePath
Write-Output "Complete"I recognize that this "works" but this is far from ideal.
Version
GA
What database are you using?
Azure SQL
What hosting model are you using?
Local (including CLI)
Which API approach are you accessing DAB through?
REST, GraphQL
Relevant log output
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
Done