WeatherApp is a .NET 9.0 project that includes a CLI tool and a Web API for fetching weather data.
- Requirements
- Auth
- Build Instructions
- Publish Instructions
- Running Tests
- Running the Web API
- Launching Docker Container
- Accessing the Swagger Documentation
- WeatherApp CLI
- TODO
- Data Source
- .NET 9.0 SDK
- Docker (optional, for containerized runs)
- Internet connection for weather API access
- OpenWeather Free API key - https://home.openweathermap.org/users/sign_up
This project requires an OpenWeather Free API key for calls to the geolocation and weather services.
https://home.openweathermap.org/users/sign_up
The environment variable 'OPENWEATHER_API_KEY' must be set.
- For vscode debugging and running via
dotnetcommand, it can be set insrc/WeatherApp.Api/Properties/launchSettings.json - For docker, it can be passed with the
runcommand by replacing<REPLACE_ME>
docker run -e OPENWEATHER_API_KEY=<REPLACE_ME> -p 5000:5000 --rm weatherapp:latestFrom the repo root:
dotnet builddocker build -t weatherapp:latest .Publish the Web API or CLI app for deployment:
dotnet publish -c Releasedotnet testBy default, the API runs on port 5000:
dotnet run --project src/WeatherApp.ApiOr, if published:
dotnet src/WeatherApp.Api/bin/Release/net9.0/WeatherApp.Api.dll
Run the container and expose port 5000:
docker run -e OPENWEATHER_API_KEY=<REPLACE_ME> --rm -p 5000:5000 weatherapp:latest- ensure you replace <REPLACE_ME> with your OPENWEATHER_API_KEY.
- --rm ensures the container is removed when stopped.
- Port 5000 on host maps to port 5000 in container.
Once the Web API is running, open: http://localhost:5000/swagger
Note, WeatherApp.Api must be running as the CLI makes requests to the WeatherApp.Api.
Description:
WeatherApp CLI tool for fetching weather data
Usage:
WeatherApp.Cli [command] [options]
Options:
-?, -h, --help Show help and usage information
--version Show version information
Commands:
get-current-weather <zipcode> <Celsius|Fahrenheit> Get current weather for a zip code
get-average-weather <zipcode> <Celsius|Fahrenheit> <days> Get average weather for a zip code over a 2-5 day periodWeatherApp.Cli get-current-weather 01440 Fahrenheit --output JSON
WeatherApp.Cli get-average-weather 01440 Celsius 3 --output TEXT- CLI validation
- CLI error handling
- Enable OAuth
- Add additional unit tests
- Add end to end integration tests
- Shared secret store for API key
- Use code formatter
This project uses weather data provided by OpenWeather. Data is fetched via the OpenWeather Free API. All weather data is © OpenWeather.