The Skeddly SDK for .NET enables .NET developers to easily work with Skeddly and automate their Amazon Web Services resources.
The Skeddly SDK for .NET is compatible with the following frameworks:
- .NET Framework 4.6.1 (and later)
- .NET Core 2.0 (and later)
- .NET Standard 2.0 (and later)
Install the Skeddly SDK for .NET from Nuget:
Install-Package SkeddlySDK
- SkeddlySDK
- This package is the core SDK.
- SkeddlySDK.Extensions.NETCore.Setup
- This package includes extension methods to help configuration of .NET Core applications.
The SkeddlyClient
object has a constructor that can take your Skeddly API key as a parameter:
var client = new SkeddlyClient("sk_12345678901234567890");
The Skeddly SDK has built-in configuration using Web.config and App.config. Add the following to your configuration file:
<appSettings>
<add key="SkeddlyAccessKeyId" value="your access key" />
</appSettings>
Once configured, you can use the default constructor to create the client:
var client = new SkeddlyClient();
.NET Core application uses a different mechanism for configuration.
Instead of using ConfigurationManager
, .NET Core applications use a configuration
provider based on IConfiguration
.
To make configuration easy, install a second package from Nuget:
Install-Package SkeddlySDK.Extensions.NETCore.Setup
Common practice is to use an appsettings.json
file to store your application settings.
Include a Skeddly
object like the following.
{
"Skeddly": {
"AccessKeyId": "your access key"
}
}
To load this configuration in your application, use the GetSkeddlyOptions
extension
method to get a SkeddlyOptions
object. Using that, call CreateClient
to create the client.
using Skeddly;
...
var options = Configuration.GetSkeddlyOptions();
var client = options.CreateClient();
You can also use the .NET Core dependency injection system to create your Skeddly client.
In Startup.cs
, (hopefully) you'll find a ConfigureServices
method:
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
}
The SkeddlySDK.Extensions.NETCore.Setup
assembly adds extension methods to IServiceCollection
that you can use to add the Skeddly client to the dependency injection.
using Skeddly;
...
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
// Add the Skeddly configuration and client into the dependency injection pipeline
services.AddDefaultSkeddlyOptions(Configuration.GetSkeddlyOptions());
services.AddSkeddlyClient();
}
Then, in your MVC controllers, add an ISkeddlyClient
parameter to the constructor.
using Skeddly;
...
public class HomeController : Controller
{
ISkeddlyClient _skeddlyClient;
public HomeController(ISkeddlyClient skeddlyClient)
{
_skeddlyClient = skeddlyClient;
}
...
}