{"id":27076411,"url":"https://github.com/mjul/avro-dotnet-lab","last_synced_at":"2026-05-07T02:33:21.704Z","repository":{"id":45105970,"uuid":"237936177","full_name":"mjul/avro-dotnet-lab","owner":"mjul","description":"Example of using Apache Avro on .NET","archived":false,"fork":false,"pushed_at":"2022-01-08T00:39:56.000Z","size":57,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T00:31:55.124Z","etag":null,"topics":["avro","csharp","dotnet","fsharp"],"latest_commit_sha":null,"homepage":null,"language":"F#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mjul.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-03T10:09:19.000Z","updated_at":"2023-08-12T15:29:53.000Z","dependencies_parsed_at":"2022-09-18T12:21:09.088Z","dependency_job_id":null,"html_url":"https://github.com/mjul/avro-dotnet-lab","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mjul/avro-dotnet-lab","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjul%2Favro-dotnet-lab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjul%2Favro-dotnet-lab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjul%2Favro-dotnet-lab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjul%2Favro-dotnet-lab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mjul","download_url":"https://codeload.github.com/mjul/avro-dotnet-lab/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjul%2Favro-dotnet-lab/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32720145,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-07T02:14:30.463Z","status":"ssl_error","status_checked_at":"2026-05-07T02:14:29.405Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["avro","csharp","dotnet","fsharp"],"created_at":"2025-04-06T00:30:58.186Z","updated_at":"2026-05-07T02:33:21.690Z","avatar_url":"https://github.com/mjul.png","language":"F#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Using Apache Avro on .NET\n\nThe [Apache Avro](https://avro.apache.org/) serialization format is quite useful (_e.g._ for Kafka Streams) or \nwhen you need to have a schema for your data exchange.\n\nYou will face three problems using it on .NET, however:\n\n1. The .NET documentation is quite sparse.\n2. There are multiple implementations, so you will need to pick the right one.\n3. None of the .NET implementations are complete and support the full Avro spec (_e.g._ logical types)\n\nThis repository contains an example of how to work with Avro in C# and F#.\n\n- The Avro schemas are defined in the [`src\\idl`](src/idl) folder.\n- Classes for schema types are generated with `avrogen`, see the [GeneratedSchemaTypes](src/csharp/GeneratedSchemaTypes) project.\n- The F# tool to read and write records is in [src\\fsharp\\AvroFSharp](src/fsharp/AvroFSharp)\n- The C# tool is in [src\\csharp\\AvroCSharp](src/csharp/AvroCSharp)\n\n## Building the Code\n\nThe code uses the [Fake](https://fake.build) command-line tool to build:\n\nThe tools are described in the `.config\\dotnet-tools.json` manifest, \nso you only have to and issue the installation and build command:\n\n    dotnet tool restore\n    dotnet fake build\n\nThe build itself is described in the [`build.fsx`](build.fsx) file.\n\n## Running the Code \n\nGet usage:\n\n    dotnet run --project src\\csharp\\AvroCSharp\n\nSave a record to an Avro file container in the tmp directory:\n\n    dotnet run --project src\\csharp\\AvroCSharp save-file tmp\\transfer.avro\n\nor\n\n    dotnet run --project src\\fsharp\\AvroFSharp save-file tmp\\transfer.avro\n\nLoad the record from the Avro file container:\n\n    dotnet run --project src\\csharp\\AvroCSharp load-file tmp\\transfer.avro\n\nor\n\n     dotnet run --project src\\fsharp\\AvroFSharp load-file tmp\\transfer.avro    \n\n\n## Avro Tools\n\nThe best Avro tools are only available Java tools jar.\nYou can get them here:\n\n```PowerShell\n    wget http://www.us.apache.org/dist/avro/avro-1.9.2/java/avro-tools-1.9.2.jar -OutFile avro-tools-1.9.2.jar\n```\n\nThe command-line tool will list all its possibilities if you invoke it like this:\n\n    java -jar avro-tools-1.9.2.jar\n\nIt has useful tools for showing querying file schemas and metadata, converting between binary and human-readable text \nrepresentations of you data (text and json), compiling schema IDL to the JSON schema format.\n\nIf you have saved an Avro file with the applications in `tmp\\transfer.avro` you can use the tools like this:\n\nGet the schema from the container using Avro Tools (see below):\n\n    java -jar avro-tools-1.9.2.jar getschema tmp\\transfer.avro    \n\nRead the Avro File as JSON:\n\n    java -jar .\\avro-tools-1.9.2.jar tojson .\\tmp\\transfer.avro\n\n## Defining Schemas\n\nAvro offers a succinct IDL format and a verbose JSON format to describe \nthe schemas and protocols.\n\nThe definitions are in the [`src\\idl`](src/idl) folder.\n\n### Logical Types\nNote that there is no support for converting .NET types to and from `logicalTypes` yet (_e.g._ to date or fixed decimal) in the Apache Avro library nor in the Confluent fork.\nIt is supported in _e.g._ the Java library. It is underway in PR [AVRO-2359: Support Logical Types in C#](https://github.com/apache/avro/pull/492).\n\n\n## Code Generation\nI tried different code generators.\n\nAt the time of writing (February 2020) the Confluent fork is the most mature,\nbut it has been incorporated into the official Apache tooling and\nwill be discontinued when it is released with the Avro 1.10 release (soon?).\n\nMy advice is to use `Apache.Avro` and the code-generator `Apache.Avro.Tools` unless\nthere is something in the Confluent fork you absolutely need for the moment.\n\n### Chr.Avro Code Generator\n\nThe [Chr.Avro](https://engineering.chrobinson.com/dotnet-avro/) code generator looked promising, but\ncould not handle union types (_e.g._ the two types of bank accounts in the example IDL):\n\n    dotnet tool install Chr.Avro.Cli --global\n\nThen, \n\n    Get-Content .\\idl\\transfers.avsc | dotnet avro generate | Out-File .\\src\\csharp\\GeneratedSchemaTypes\\generated\\Transfers.cs\n\nConclusion: *Not recommended.*\n\n### Confluent Code Generator\n\nThe [Confluent Code Generator](https://www.nuget.org/packages/Confluent.Apache.Avro.AvroGen/) does a better job.\nUnions are represented as the .NET type `object` but that will do.\n\nYou can install it as a global tool like this:\n\n    dotnet tool install -g Confluent.Apache.Avro.AvroGen\n\nThen to generate the code:\n\n    avrogen -s .\\idl\\transfers.avsc  .\\src\\csharp\\GeneratedSchemaTypes\\generated\\\n\nNote that it is being deprecated since Apache has started updating their tool again.\n\n### Apache Avro Tools Code Generator\n\nIn the end this is what we are using. After some years of not being good enough, it has now caught up with the Confluent fork and\nonce 1.10 is release (in 2020?) the Confluent fork will be discontinued.\n\nTo install into the `dotnet-tools.json` manifest (already done):\n\n    dotnet tool install Apache.Avro.Tools --version 1.9.1\n\nThen to install the local tools:\n\n    dotnet tool restore\n\nAnd to generate the code into the `generated` directory:\n\n    dotnet avrogen .\\idl\\transfers.avsc  .\\src\\csharp\\GeneratedSchemaTypes\\generated\\\n\n\n\n## Developer Information\n\nThe C# project is a skeleton project file used to build the generated code when the Avro schemas have been compiled.\n\n### Visual Studio Code\n\nConfigure VS code to use [dotnet fsi](https://github.com/ionide/ionide-vscode-fsharp/issues/1237).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjul%2Favro-dotnet-lab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmjul%2Favro-dotnet-lab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjul%2Favro-dotnet-lab/lists"}