PythonAppResourceBuilderExtensions.WithEntrypoint<T> Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Configures the entrypoint for the Python application.
public static Aspire.Hosting.ApplicationModel.IResourceBuilder<T> WithEntrypoint<T>(this Aspire.Hosting.ApplicationModel.IResourceBuilder<T> builder, Aspire.Hosting.Python.EntrypointType entrypointType, string entrypoint) where T : Aspire.Hosting.Python.PythonAppResource;
static member WithEntrypoint : Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.Python.PythonAppResource)> * Aspire.Hosting.Python.EntrypointType * string -> Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.Python.PythonAppResource)> (requires 'T :> Aspire.Hosting.Python.PythonAppResource)
<Extension()>
Public Function WithEntrypoint(Of T As PythonAppResource) (builder As IResourceBuilder(Of T), entrypointType As EntrypointType, entrypoint As String) As IResourceBuilder(Of T)
Type Parameters
- T
Parameters
- builder
- IResourceBuilder<T>
The resource builder.
- entrypointType
- EntrypointType
The type of entrypoint (Script, Module, or Executable).
- entrypoint
- String
The entrypoint value (script path, module name, or executable name).
Returns
A reference to the IResourceBuilder<T> for method chaining.
Examples
Change a Python app from running a script to running a module:
var python = builder.AddPythonScript("api", "../python-api", "main.py")
.WithEntrypoint(EntrypointType.Module, "uvicorn")
.WithArgs("main:app", "--reload");
Remarks
This method allows you to change the entrypoint configuration of a Python application after it has been created. The command and arguments will be updated based on the specified entrypoint type:
- Script: Runs as
python <scriptPath> - Module: Runs as
python -m <moduleName> - Executable: Runs the executable directly from the virtual environment
Important: This method resets all command-line arguments. If you need to add arguments after changing the entrypoint, call WithArgs after this method.