Brian Newman
07/01/2025, 12:20 AMMarvin
07/01/2025, 12:20 AMMarvin
07/01/2025, 12:21 AMcontainer_name
parameter when creating your infrastructure block.
Here's how to do it:
python
from prefect_azure.container_instance import AzureContainerInstanceInfrastructure
aci = AzureContainerInstanceInfrastructure(
container_name="${flow_run.id}", # This will use just the flow run ID
# ... other configuration options ...
)
You can use any of these variables in your container name:
- `${flow_run.id}`: Just the flow run ID
- `${flow_run.name}`: The flow run name
- `${deployment.name}`: The deployment name
The ${flow_run.id}
option is particularly useful as it will give you a shorter, unique identifier for each container.
If you're setting this up via the UI:
1. Go to the Blocks page
2. Create or edit your Azure Container Instance block
3. In the "Container Name" field, enter ${flow_run.id}
This will ensure your container names stay well under Azure's 64-character limit while maintaining uniqueness for each run.
Note: Make sure you're using the latest version of prefect-azure
to ensure you have all the latest features and fixes for Azure Container Instance integration.Brian Newman
07/01/2025, 12:22 AMprefect.yaml
to deploy though.Marvin
07/01/2025, 12:22 AMMarvin
07/01/2025, 12:22 AMprefect.yaml
configuration file. Here's how to modify your prefect.yaml
to set the container name:
yaml
deployments:
- name: your-deployment-name
version: null
tags: []
description: null
schedule: null
flow_name: null
entrypoint: null
parameters: {}
work_pool:
name: your-azure-work-pool
work_queue_name: default
job_variables:
container_name: ${flow_run.id} # This will use just the flow run ID
The container_name
goes under job_variables
in your work pool configuration. This will override the default naming convention and use just the flow run ID for the container name, keeping it well under Azure's 64-character limit.
If you have multiple deployments in your prefect.yaml
, you can apply this to each deployment where you want to customize the container name.Brian Newman
07/01/2025, 12:27 AMMarvin
07/01/2025, 12:27 AMMarvin
07/01/2025, 12:28 AMprefect.yaml
job variables. This suggests my previous advice may have been incorrect.
Could you try creating an issue on the prefect-azure repository to request this feature or get clarification? This seems like a legitimate limitation that should be addressed.
In the meantime, you might need to configure this at the work pool level through the UI or via the Python API when creating the work pool, rather than in the prefect.yaml
.
I apologize I couldn't provide a more definitive solution. Would you like me to explain how to configure this through the work pool settings instead?Brian Newman
07/01/2025, 12:31 AMMarvin
07/01/2025, 12:31 AMMarvin
07/01/2025, 12:31 AMcontainer_name
variable and the work pool settings.
This appears to be a limitation with the current Azure Container Instance push implementation. Would you mind opening an issue on the prefect-azure repository to report this problem? The 64-character limit in Azure is a real constraint, and Prefect should provide a way to customize the container naming convention to work within this limitation.
In the meantime, you might want to consider:
1. Using shorter deployment names to stay under the limit
2. Switching to pull mode if that's an option in your architecture
3. Using a different infrastructure type if possible
I apologize I couldn't provide a direct solution to override the name. Would you like me to explain any of these alternative approaches?