<@ULVA73B9P> should block strings and json blocks ...
# ask-marvin
m
@Marvin should block strings and json blocks be migrated to variables in prefect v3?
m
thought for 224.7 seconds
Short answer: Yes. In Prefect 3.x, simple String and JSON Blocks should be migrated to Variables. Variables are the recommended way to store small, non-sensitive configuration values. Keep using Secret blocks for sensitive data (API keys, passwords) since Variables are not encrypted. Why: - Variables are first-class in Prefect 3.x for config and metadata - Simpler API and CLI; great for values that change without redeploying - Secret blocks remain the right choice for sensitive values Python examples
Copy code
from prefect.variables import Variable

# Set values
Variable.set("api_base_url", "<https://api.example.com>")
Variable.set("db_config", {"host": "localhost", "port": 5432})

# Get values
api_base_url = Variable.get("api_base_url")
db_config = Variable.get("db_config", default={"host": "localhost", "port": 5432})
CLI examples
Copy code
# Set
prefect variable set api_base_url "<https://api.example.com>"
prefect variable set db_config '{"host":"localhost","port":5432}' --overwrite

# Get
prefect variable get api_base_url
prefect variable get db_config
Notes - Variables store JSON-serializable values and are visible in the UI (not encrypted) - Use Secret blocks for real secrets - You can reference Variables in deployments via Jinja, e.g.
{{ prefect.variables.api_base_url }}
Docs - Variables - Blocks - Secrets If you want, share an example of how you’re using String/JSON blocks today and I can show the exact migration.