{"id":751,"date":"2026-10-12T14:28:38","date_gmt":"2026-10-12T04:28:38","guid":{"rendered":"https:\/\/www.cloudproinc.com.au\/?p=751"},"modified":"2026-10-12T14:28:38","modified_gmt":"2026-10-12T04:28:38","slug":"generate-dall-e-images-with-net-c-console-application","status":"publish","type":"post","link":"https:\/\/www.cloudproinc.com.au\/index.php\/2026\/10\/12\/generate-dall-e-images-with-net-c-console-application\/","title":{"rendered":"Generate DALL-E Images with .NET C# Console Application"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This Azure OpenAI article will show you how to generate DALL-E images with .NET C# Console application using the Azure SDK for .NET.<\/p>\n\n\n\n<!--more-->\n\n\n\n<div class=\"wp-block-yoast-seo-table-of-contents yoast-table-of-contents\"><h2>Table of contents<\/h2><ul><li><a href=\"#h-azure-sdk-for-net\" data-level=\"2\">Azure SDK for .NET<\/a><\/li><li><a href=\"#h-generate-dall-e-images-with-net-c-console-application\" data-level=\"2\">Generate DALL-E Images with .NET C# Console Application<\/a><\/li><li><a href=\"#h-install-package\" data-level=\"2\">Install-Package<\/a><\/li><li><a href=\"#h-program-cs\" data-level=\"2\">Program.cs<\/a><\/li><li><a href=\"#h-related-articles\" data-level=\"2\">Related Articles<\/a><\/li><\/ul><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Azure SDK for .NET allows us to build Gen-AI applications using .NET, the C# programming language. We, the SDK, can build Blazor and Console apps using C# and mobile apps. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">DALL-E version 3 allows us to generate high-definition images from a text input. Currently, we can access the service from the Azure OpenAI studio using the DALL-E playground and RAST API with Postman and C#.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-azure-sdk-for-net\">Azure SDK for .NET<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The Azure SDK for .NET allows us to create and manage Azure resources using the .NET language. To create and manage Azure OpenAI service, we use <strong>Azure.AI, The OpenAI <\/strong>package library. The libraries are available in NuGet.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-generate-dall-e-images-with-net-c-console-application\">Generate DALL-E Images with .NET C# Console Application<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To generate DALL-E images, we first need to create an Azure OpenAI resource with an OpenAI deployment. Once your service is deployed, note the endpoint and API Key.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For the application to run, we need to create two environment variables. One is for the Azure OpenAI resource endpoint, and the second is for the API Key.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Below is an example of a PowerShell code that creates the two environment variables.<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-1\"><code>$env:AZURE_OPENAI_ENDPOINT=\"Endpoint\"\n$env:AZURE_OPENAI_API_KEY=\"API Key\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you use VS Code, run the code from the VS Code terminal window.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-install-package\">Install-Package<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After creating a C# console application, install the Azure OpenAI NuGet library.<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-2\"><code>dotnet add package Azure.AI.OpenAI --version 1.0.0-beta.17<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-program-cs\">Program.cs<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The following code will generate an Image from the Azure OpenAI DALL-E model. Make sure you set the <strong>DeploymentName <\/strong>to the name of your DALL-E deployment name.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the Prompt, describe the name of the image you would like to generate and run the application.<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-3\"><code>using static System.Environment;\nusing System.IO;\nusing System.Threading.Tasks;\nusing Azure.AI.OpenAI;\n\nnamespace Azure.AI.OpenAI.Tests.Samples\n{\n    public partial class GenerateImages\n    {\n        \/\/ Get the environment variable\n        public static async Task Main(string&#91;] args)\n        {\n            string endpoint = GetEnvironmentVariable(\"AZURE_OPENAI_ENDPOINT\");\n            string key = GetEnvironmentVariable(\"AZURE_OPENAI_API_KEY\");\n\n            OpenAIClient client = new(new Uri(endpoint), new AzureKeyCredential(key));\n\n            \/\/ Get the image generations asynchronously\n            Response&lt;ImageGenerations&gt; imageGenerations = await client.GetImageGenerationsAsync(\n                new ImageGenerationOptions()\n                {\n                    DeploymentName = \"dall-e-3\",\n                    Prompt = \"Createa blog post cover for a blog post about DALL-E\",\n                    Size = ImageSize.Size1024x1024,\n\n                });\n\n           \n            Uri imageUri = imageGenerations.Value.Data&#91;0].Url;\n            \n           \n            Console.WriteLine(imageUri);\n        }\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">After running the application, you will get a URL that contains the generated image. The link will be valid for 60 minutes and will be deleted after.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-related-articles\">Related Articles<\/h2>\n\n\n\n<ul class=\"wp-block-yoast-seo-related-links yoast-seo-related-links\">\n<li><a href=\"https:\/\/cloudproinc.com.au\/index.php\/2024\/07\/22\/generate-an-image-caption-with-azure-ai-vision-and-net\/\">Generate an Image Caption With Azure AI Vision and .NET<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/cloudproinc.com.au\/index.php\/2024\/07\/21\/integrating-azure-ai-vision-for-image-analysis-in-c-applications\/\">Integrating Azure AI Vision for Image Analysis in C# Applications<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.cloudproinc.com.au\/index.php\/2024\/05\/06\/upgrading-windows-11-editions-made-easy-with-microsoft-intune\/\">Upgrading Windows 11 Editions Made Easy with Microsoft Intune<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.cloudproinc.com.au\/index.php\/2024\/10\/07\/deploy-azure-openai-resource-using-bicep\/\">Deploy Azure OpenAI Resource Using Bicep<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.cloudproinc.com.au\/index.php\/2024\/07\/25\/how-to-deploy-a-wiz-outpost-to-microsoft-azure\/\">How to Deploy a Wiz Outpost to Microsoft Azure<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This Azure OpenAI article will show you how to generate DALL-E images with .NET C# Console application using the Azure SDK for .NET.<\/p>\n","protected":false},"author":1,"featured_media":460,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"off","_et_pb_old_content":"","_et_gb_content_width":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[27,24,54,53],"tags":[],"class_list":["post-751","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-net","category-ai","category-dall-e","category-openai"],"jetpack-related-posts":[{"id":53079,"url":"https:\/\/www.cloudproinc.com.au\/index.php\/2026\/10\/12\/running-c-net-applications-in-azure-devops-pipelines\/","url_meta":{"origin":751,"position":0},"title":"Running C# .NET Applications in Azure DevOps Pipelines","author":"CPI Staff","date":"October 12, 2026","format":false,"excerpt":"In this blog post, I will show you how to build and run a C# application in Azure DevOps Pipelines. Estimated reading time: 3 minutes Table of contentsWhat Are Azure Pipelines?Step 1: Build the Console ApplicationStep 2: Create a YAML PipelineStep 3: Create a New PipelinePipeline Execution OverviewSummaryRelated Articles What\u2026","rel":"","context":"In &quot;.NET&quot;","block_context":{"text":".NET","link":"https:\/\/www.cloudproinc.com.au\/index.php\/category\/net\/"},"img":{"alt_text":"","src":"\/wp-content\/uploads\/2025\/01\/Running-C-.NET-Applications-in-Azure-DevOps-Pipelines.webp","width":350,"height":200,"srcset":"\/wp-content\/uploads\/2025\/01\/Running-C-.NET-Applications-in-Azure-DevOps-Pipelines.webp 1x, \/wp-content\/uploads\/2025\/01\/Running-C-.NET-Applications-in-Azure-DevOps-Pipelines.webp 1.5x, \/wp-content\/uploads\/2025\/01\/Running-C-.NET-Applications-in-Azure-DevOps-Pipelines.webp 2x"},"classes":[]},{"id":780,"url":"https:\/\/www.cloudproinc.com.au\/index.php\/2026\/10\/12\/creating-a-storage-container-in-azure-using-azure-sdk-for-net\/","url_meta":{"origin":751,"position":1},"title":"Creating a Storage Container in Azure Using Azure SDK for .NET","author":"CPI Staff","date":"October 12, 2026","format":false,"excerpt":"In this\u00a0\u00a0Microsoft Azure\u00a0article, we will create a storage container inside an Azure storage account using Azure SDK for .NET. Estimated reading time: 3 minutes Table of contentsCreating a Storage Container in Azure Using Azure SDK for .NETCreate Storage AccountRetrieve Storage Account Connection String Using PowerShellCreate C# Console ApplicationCreate an Environment\u2026","rel":"","context":"In &quot;.NET&quot;","block_context":{"text":".NET","link":"https:\/\/www.cloudproinc.com.au\/index.php\/category\/net\/"},"img":{"alt_text":"","src":"\/wp-content\/uploads\/2024\/07\/Reading-Handwriting-with-Azure-AI-Vision-and-.NET-C.webp","width":350,"height":200,"srcset":"\/wp-content\/uploads\/2024\/07\/Reading-Handwriting-with-Azure-AI-Vision-and-.NET-C.webp 1x, \/wp-content\/uploads\/2024\/07\/Reading-Handwriting-with-Azure-AI-Vision-and-.NET-C.webp 1.5x, \/wp-content\/uploads\/2024\/07\/Reading-Handwriting-with-Azure-AI-Vision-and-.NET-C.webp 2x"},"classes":[]},{"id":753,"url":"https:\/\/www.cloudproinc.com.au\/index.php\/2026\/10\/12\/generate-images-with-azure-openai-dall-e-and-postman\/","url_meta":{"origin":751,"position":2},"title":"Generate Images with Azure OpenAI DALL-E and Postman","author":"CPI Staff","date":"October 12, 2026","format":false,"excerpt":"In this Azure OpenAI DALL-E article, we will show you how to generate images with Azure OpenAI DALL-E and Postman. Table of contentsDeploy Resource and AI ModelGenerate Images with Azure OpenAI DALL-E and PostmanRelated Articles Azure OpenAI DALL-E offers the latest text-to-image generation model, DALL-E 3. The model offers advanced\u2026","rel":"","context":"In &quot;Azure OpenAI&quot;","block_context":{"text":"Azure OpenAI","link":"https:\/\/www.cloudproinc.com.au\/index.php\/category\/azure-openai\/"},"img":{"alt_text":"","src":"\/wp-content\/uploads\/2024\/07\/How-to-Use-Microsoft-Graph-Security-API.webp","width":350,"height":200,"srcset":"\/wp-content\/uploads\/2024\/07\/How-to-Use-Microsoft-Graph-Security-API.webp 1x, \/wp-content\/uploads\/2024\/07\/How-to-Use-Microsoft-Graph-Security-API.webp 1.5x, \/wp-content\/uploads\/2024\/07\/How-to-Use-Microsoft-Graph-Security-API.webp 2x, \/wp-content\/uploads\/2024\/07\/How-to-Use-Microsoft-Graph-Security-API.webp 3x, \/wp-content\/uploads\/2024\/07\/How-to-Use-Microsoft-Graph-Security-API.webp 4x"},"classes":[]},{"id":784,"url":"https:\/\/www.cloudproinc.com.au\/index.php\/2026\/10\/12\/create-an-app-registration-for-microsoft-azure-sdk-for-net\/","url_meta":{"origin":751,"position":3},"title":"Create an App Registration for Microsoft Azure SDK for .NET","author":"CPI Staff","date":"October 12, 2026","format":false,"excerpt":"In this\u00a0\u00a0Azure\u00a0REST API post, I will show you how to create an App Registration for Microsoft Azure SDK for .NET. Azure SDK for .NET allows us to manage Azure programmatically using .NET libraries. Using the SDK, we can create and manage any Azure resource. The Azure SDK for .NET has\u2026","rel":"","context":"In &quot;.NET&quot;","block_context":{"text":".NET","link":"https:\/\/www.cloudproinc.com.au\/index.php\/category\/net\/"},"img":{"alt_text":"","src":"\/wp-content\/uploads\/2024\/09\/create-an-Azure-AI-Translator-service-using-the-Azure-REST-API.webp","width":350,"height":200,"srcset":"\/wp-content\/uploads\/2024\/09\/create-an-Azure-AI-Translator-service-using-the-Azure-REST-API.webp 1x, \/wp-content\/uploads\/2024\/09\/create-an-Azure-AI-Translator-service-using-the-Azure-REST-API.webp 1.5x, \/wp-content\/uploads\/2024\/09\/create-an-Azure-AI-Translator-service-using-the-Azure-REST-API.webp 2x"},"classes":[]}],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"\/wp-content\/uploads\/2024\/07\/Reading-Handwriting-with-Azure-AI-Vision-and-.NET-C.webp","_links":{"self":[{"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/posts\/751","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/comments?post=751"}],"version-history":[{"count":1,"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/posts\/751\/revisions"}],"predecessor-version":[{"id":752,"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/posts\/751\/revisions\/752"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/media\/460"}],"wp:attachment":[{"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/media?parent=751"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/categories?post=751"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/tags?post=751"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}