Skip to content

Start a dev container and get to developing .NET apps leveraging a variety of Azure services.

License

Notifications You must be signed in to change notification settings

alertbox/try-dotnet-on-azure

Repository files navigation

Tryout .NET & Azure Stuff

.NET C-sharp

This template repo serves as a flavor of ready-to-go .NET and Azure development container.

Originally, this dev container was created to tryout .NET preview versions without having to install them locally.

What's included:

Technically, this includes nothing but:

  • .NET 7 Latest SDK and Azure CLI with Bicep
  • Docker and Kubernetes with Helm Charts, and
  • Configured to build and run from VS Code

Requirements

See dev containers to get started at the most basic level, and:

Quick Start

If you are completely new to .NET and C#, the .NET Learning Center is a good source of information. Or follow this generic pattern:

First you want a copy of this repo. It is marked as a Template so you will only have to Use this template and follow the instructions. Read more about this in the GitHub's Template Repositories document.

With Dev Container CLI:

Just run devcontainer up devcontainers-try-dotnet-stuff/ in the repo. And that's it!

With VS Code:

First. run code devcontainers-try-dotnet-stuff/ in the repo to open in VS Code, and then it'll propmpt to Reopen in Container. Do that and we're all set!

Things to Tryout

First, you want to ensure the repo is Reopened in Container. Then you'll be able to work on .NET and Azure stuff like you would locally.

With VS Code:

  1. In a Terminal, run dotnet --info to see required versions are installed.
  2. Run az --version to verify Azure CLI is installed.

Create a minimal API

Next, you would want to create a .NET project, say, a Minimal API test-project that ships with .NET Template projects.

With VS Code:

  1. Run dotnet new to create a new web api with specific template.

    dotnet new webapi -o src\test-project \
                      --use-minimal-apis \
                      --language "C#"
  2. Open the launchSettings.json file, then change the test_project profile to run on port 5000 for HTTP and 5001 for HTTPS.

    "profiles": {
      "test_project": {
        // ...
        "applicationUrl": "https://localhost:5001;http://localhost:5000",
        // ...
    }

Build and run from source

VS Code is integrated with Omnisharp Tools to run the web api on the dev container.

With VS Code:

  1. Press F5 to launch the web api project. Terminal shows the output from the Debug Console.
  2. When the web api executes, visit localhost:5001/swagger on your favorite browser.
  3. Press Ctrl+C to stop and disconnect the debugger.

Known issues

Useful Resources

Feedback

If you have any technical problems with dev containers, you are better off asking Dev Containers Support directly, since you'll end up getting a much faster response back that way.

Contributing

The official repo to contribute would be @devcontainers.

Have a suggestion or a bug fix? Just open a pull request or an issue. Include clear and simple instructions possible.

License

Copyright (c) Alertbox Inc. All rights reserved.

The source code is license under the MIT license.