> ## Documentation Index
> Fetch the complete documentation index at: https://cloudinary.com/documentation/llms.txt
> Use this file to discover all available pages before exploring further.

# .NET quick start


[readme-version-support-link]:https://github.com/cloudinary/CloudinaryDotNet#version-support
This quick start lets you get an end-to-end implementation up and running using the .NET SDK in 5 minutes or less.

#### Prerequisites **To perform this quick start, you'll need:**

* A Cloudinary account. If you don't have one yet, you can quickly [register for free](https://cloudinary.com/users/register_free).
* Your product environment credentials. You can find your [credentials](product_environment_settings#api_keys) on the [API Keys](https://console.cloudinary.com/app/settings/api-keys) page of the Cloudinary Console Settings. 
  * To use your **API environment variable**, copy the provided format and replace the `<your_api_key>` and `<your_api_secret>` placeholders with the actual values found on the page. Your cloud name will already be correctly included in the format.
* A working .NET development environment with a [supported version][readme-version-support-link] of .NET.

> **NOTES**:
>
> * This quick start is designed for quick onboarding.  It doesn't necessarily employ coding best practices and the code you create here isn't intended for production.  

> * If you aren't familiar with Cloudinary, you may want to first take a look at the [Developer Kickstart](dev_kickstart) for a hands-on, step-by-step introduction to Cloudinary features. You may also find our [Glossary](cloudinary_glossary) helpful to understand Cloudinary-specific terminology.
## 1. Set up and configure the library

Using a clean .NET console project or [.NET fiddle](https://dotnetfiddle.net/), add CloudinaryDotNet and dotenv.net using the Nuget Package Manager or if using the Package Manager Console, run: 

```
Install-Package CloudinaryDotNet
Install-Package dotenv.net
```

Then, in your project, create a file called `.env` and add the following line with your Cloudinary environment variable:

.env

```
# Copy and paste your API environment variable
# =============================================

CLOUDINARY_URL=cloudinary://<API_KEY>:<API_SECRET>@<CLOUD_NAME>
```

Using .NET fiddle?

.NET fiddle does not support the use of environment variables. In this case, include your credentials in your `Program.cs` file:

```
Cloudinary cloudinary = new Cloudinary("cloudinary://<api_key:<api_secret>@<cloudname>");
```

> **INFO**: When writing your own applications, follow your organization's policy on storing secrets and don't expose your API secret.

In your code, include the following `CloudinaryDotNet` libraries as well as the `dotenv.net` library in your project.

You can then load your Cloudinary credentials from your .env file as shown below. Copy and paste the following code into your `Program.cs` file:

Program.cs

```csharp
// Import the required packages
//==============================

using CloudinaryDotNet;
using CloudinaryDotNet.Actions;
using dotenv.net;

// Set your Cloudinary credentials
//=================================

DotEnv.Load(options: new DotEnvOptions(probeForEnv: true));
Cloudinary cloudinary = new Cloudinary(Environment.GetEnvironmentVariable("CLOUDINARY_URL"));
cloudinary.Api.Secure = true;

```

Tip

You can set any [configuration parameters](cloudinary_sdks#configuration_parameters) in this way.

## 2. Upload an image

Copy and paste the following code into your Program.cs file:

Program.cs (continued)

```csharp

// Upload an image and log the response to the console
//=================

var uploadParams = new ImageUploadParams()
{
    File = new FileDescription(@"https://cloudinary-devs.github.io/cld-docs-assets/assets/images/cld-sample.jpg"),
    UseFilename = true,
    UniqueFilename = false,
    Overwrite = true
};
var uploadResult = cloudinary.Upload(uploadParams);
Console.WriteLine(uploadResult.JsonObj);

```

More info about upload...

* You can upload from various sources, including local files, but this quick start uses a remote file available at: 
[https://cloudinary-devs.github.io/cld-docs-assets/assets/images/cld-sample.jpg](https://cloudinary-devs.github.io/cld-docs-assets/assets/images/cld-sample.jpg "with_code: false, with_url: false").
* The [public ID](cloudinary_glossary#public_id) in this example will use the filename of the uploaded file `cld-sample` and ensure that it is overwritten each time you run this quick start. Without these parameters set, the default option of using a random public ID would be applied, and a new asset would be created each time.
* See the `upload` method of the [Upload API](image_upload_api_reference#upload).
* Learn more about [uploading assets](upload_images).

## 3. Get details of the image

Program.cs (continued)

```csharp
// Get details of the image and run quality analysis
//==============================

var getResourceParams = new GetResourceParams("cld-sample")
{
    QualityAnalysis = true
};
var getResourceResult = cloudinary.GetResource(getResourceParams);
var resultJson = getResourceResult.JsonObj;

// Log quality analysis score to the console
Console.WriteLine(resultJson["quality_analysis"]);

```

More info about quality analysis...

* The quality analysis parameter returns a quality score between 0.0 and 1.0 for the uploaded image. This is useful when deciding if a user uploaded image meets your quality requirements. You can find more information about quality analysis in the [documentation](image_quality_analysis).

## 4. Transform the uploaded image

Program.cs (continued)

```csharp

// Transform the uploaded asset and generate a URL and image tag
//==============================

var myTransformation = cloudinary.Api.UrlImgUp.Transform(new Transformation()
    .Width(300).Crop("scale").Chain()
    .Effect("cartoonify"));

var myUrl = myTransformation.BuildUrl("cld-sample");
var myImageTag = myTransformation.BuildImageTag("cld-sample");

// Log the URL of the transformed asset to the console
Console.WriteLine(myUrl);

// Log the image tag for the transformed asset to the console
Console.WriteLine(myImageTag);

```

## 5. Run your code

Run your code by clicking the **Run** button in Visual Studio or .NET fiddle.

You can use the returned image tag to display the image on your website. For now, copy and paste the URL to see the transformed image in the browser:

![Transformed cld-sample image](https://res.cloudinary.com/demo/image/upload/c_scale,w_300/e_cartoonify/cld-sample "with_code:false")

## View the completed code

You can find the full code example for this on [GitHub](https://github.com/cloudinary-devs/dotnet-sdk-quickstart).

## Next steps
* Learn more about the .NET SDK by visiting the other pages in this SDK guide.
* Get comprehensive details about Cloudinary features and capabilities:
    * [Upload guide](upload_images): Provides details and examples of the upload options.
    * [Image transformations guide](image_transformations): Provides details and examples of the transformations you can apply to image assets.
    * [Video transformations guide](video_manipulation_and_delivery): Provides details and examples of the transformations you can apply to video assets.
    * [Transformation URL API Reference](transformation_reference): Provides details and examples of all available transformation parameters. 
    * [Admin API guide](admin_api): Provides details and examples of the methods available for managing and organizing your media assets.