Moedim.ACA.Sessions 1.0.0

dotnet add package Moedim.ACA.Sessions --version 1.0.0
                    
NuGet\Install-Package Moedim.ACA.Sessions -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Moedim.ACA.Sessions" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Moedim.ACA.Sessions" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Moedim.ACA.Sessions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Moedim.ACA.Sessions --version 1.0.0
                    
#r "nuget: Moedim.ACA.Sessions, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Moedim.ACA.Sessions@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Moedim.ACA.Sessions&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Moedim.ACA.Sessions&version=1.0.0
                    
Install as a Cake Tool

Moedim.ACA.Sessions

GitHub license NuGet Nuget

Stand With Israel

The second letter in the Hebrew alphabet is the ב bet/beit. Its meaning is "house". In the ancient pictographic Hebrew it was a symbol resembling a tent on a landscape.

A C# library for Azure Container Apps dynamic sessions - enabling secure, isolated code execution for AI agents and applications.

🚀 Overview

Moedim.ACA.Sessions provides a robust C# wrapper around Azure Container Apps' serverless code interpreter sessions, designed specifically for integration with Agentic AI frameworks where AI agents need to execute code safely and securely. This library enables AI agents to:

  • Execute Python code in isolated, sandboxed environments
  • Create and manipulate files (including PowerPoint presentations, Excel files, charts, etc.)
  • Process data and generate visualizations
  • Install and use popular Python packages (NumPy, pandas, matplotlib, etc.)
  • Maintain session state across multiple code executions

Hire me

Please send email if you consider to hire me.

buymeacoffee

Give a Star! ⭐

If you like or are using this project to learn or start your solution, please give it a star. Thanks!

Install

    dotnet add package Moedim.ACA.Sessions

Projects

Configuration

appsettings.json

{
  "ACASessions": {
    "AzureTokenProvider": {
      "RefreshBeforeMinutes": 5,
      "Scopes": [
        "https://dynamicsessions.io/.default"
      ]
    },
    "SessionsHttpClient": {
      "Endpoint": "https://{region}.dynamicsessions.io/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/sessionPools/{sessionPoolName}",
      "ApiVersion": "2024-02-02-preview"
    }
  }
}

🔐 Authentication

Azure RBAC Requirements Your application needs the following roles on the session pool:

  • Azure ContainerApps Session Executor
  • Contributor

Using Azure CLI (Development)

az account get-access-token --resource https://dynamicsessions.io

💻 Usage Examples

Basic Code Execution


// Register all ACA Sessions services
services.AddACASessions();

public class DataAnalysisAgent
{
    private readonly ICodeInterpreter _codeInterpreter;

    public DataAnalysisAgent(ICodeInterpreter codeInterpreter)
    {
        _codeInterpreter = codeInterpreter;
    }

    public async Task<string> AnalyzeDataAsync(string csvData, string sessionId)
    {
        // Upload CSV data
        await _codeInterpreter.UploadFileAsync(new FileUploadRequest
        {
            SessionId = sessionId,
            FileName = "data.csv",
            FileContent = Encoding.UTF8.GetBytes(csvData)
        }, CancellationToken.None);

        // Analyze data and create visualization
        var analysisCode = """
            import pandas as pd
            import matplotlib.pyplot as plt
            import json

            # Load and analyze data
            df = pd.read_csv('/mnt/data/data.csv')

            # Generate summary statistics
            summary = {
                'total_rows': len(df),
                'columns': list(df.columns),
                'numeric_summary': df.describe().to_dict()
            }

            # Create visualization
            plt.figure(figsize=(10, 6))
            df.hist(bins=20, figsize=(12, 8))
            plt.suptitle('Data Distribution')
            plt.tight_layout()
            plt.savefig('/mnt/data/analysis_chart.png', dpi=300, bbox_inches='tight')

            # Save analysis results
            with open('/mnt/data/analysis_results.json', 'w') as f:
                json.dump(summary, f, indent=2)

            print("Analysis complete!")
            print(f"Dataset contains {len(df)} rows and {len(df.columns)} columns")
            """;

        var result = await _codeInterpreter.ExecuteAsync(new CodeExecutionRequest
        {
            SessionId = sessionId,
            Code = analysisCode,
            SanitizeInput = true
        }, CancellationToken.None);

        return result.ToString();
    }
}

References

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 218 10/16/2025
1.0.0-preview.30 149 10/16/2025