Skip to content

Add Sora video generation sample #163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 3, 2025
Merged

Conversation

elbruno
Copy link
Collaborator

@elbruno elbruno commented Jun 3, 2025

This pull request introduces a new feature for video generation using the Azure OpenAI Sora model and updates relevant documentation and project files. The changes include adding a new lesson sample, implementing the video generation functionality, and updating the course materials to reflect the new capabilities.

New feature: Azure OpenAI Sora Video Generation

Project and functionality updates:

  • Added a new project, VideoGeneration-AzureSora-01, to the solution file CoreGenerativeAITechniques.sln. This includes the necessary configurations for building and debugging the video generation demo. [1] [2] [3]
  • Implemented the video generation functionality in Program.cs, which allows users to generate videos from text prompts using the Azure OpenAI Sora model. The implementation includes job creation, polling for status, and downloading the generated video.
  • Added a new .csproj file for VideoGeneration-AzureSora-01 with configurations for .NET 9.0, user secrets, and necessary dependencies.

Documentation updates:

  • Updated README.md to highlight the new Azure OpenAI Sora Video Generation demo, including a description of its features and links to the sample code and official documentation.
  • Updated 10-WhatsNew/readme.md to include details about the new Sora video generation demo in Lesson 3, along with instructions and links for further exploration.

These changes provide users with a hands-on example of generating videos using text prompts, enhancing the course's generative AI capabilities.

elbruno added 2 commits June 3, 2025 15:43
DETAILS

- Updated solution to include "11 Video Generation" and "VideoGeneration-AzureSora-01" projects.
- Modified `Program.cs` to implement video generation functionality with Azure's OpenAI service, including configuration loading, job creation, status polling, and video downloading.
- Created `VideoGeneration-AzureSora-01.csproj` targeting .NET 9.0 with user secrets management.
@elbruno elbruno requested a review from Copilot June 3, 2025 19:52
Copy link

github-actions bot commented Jun 3, 2025

👋 Thanks for contributing @elbruno! We will review the pull request and get back to you soon.

@elbruno elbruno merged commit 90a67cc into main Jun 3, 2025
5 of 6 checks passed
@elbruno elbruno deleted the bruno-addsora-videogeneration branch June 3, 2025 19:54
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new Azure OpenAI Sora video generation sample project to the course and updates documentation to surface the new demo.

  • Introduces a new VideoGeneration-AzureSora-01 project (net9.0) in the solution, with user secrets and sample code.
  • Implements end-to-end video generation (job creation, polling, download) in Program.cs.
  • Updates README.md and 10-WhatsNew/readme.md to highlight the Sora video generation demo.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
README.md Added Sora video generation demo to main README
10-WhatsNew/readme.md Documented June 2025 entry for Sora demo
03-CoreGenerativeAITechniques/src/VideoGeneration-AzureSora-01/VideoGeneration-AzureSora-01.csproj New project file for the video generation sample
03-CoreGenerativeAITechniques/src/VideoGeneration-AzureSora-01/Program.cs Implemented Sora video generation workflow
03-CoreGenerativeAITechniques/src/CoreGenerativeAITechniques.sln Added solution folder and project references
Comments suppressed due to low confidence (1)

10-WhatsNew/readme.md:9

  • [nitpick] The heading omits 'OpenAI' and 'Demo' compared to the main README; consider aligning it to 'Azure OpenAI Sora Video Generation Demo' for consistency.
- **New Lesson 3 Sample: Azure Sora Video Generation**


string idx = DateTime.Now.ToString("ddMMMyyyy_HHmmss");
string suffix = new string(prompt.Length > 30 ? prompt.Substring(0, 30).ToCharArray() : prompt.ToCharArray());
suffix = suffix.Replace(",", "_").Replace(".", "_").Replace(" ", "_");
Copy link
Preview

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only replacing commas, periods, and spaces may leave other invalid filename characters. Consider sanitizing suffix using Path.GetInvalidFileNameChars() or a regex to remove all invalid characters.

Suggested change
suffix = suffix.Replace(",", "_").Replace(".", "_").Replace(" ", "_");
var invalidChars = Path.GetInvalidFileNameChars();
suffix = new string(suffix.Select(c => invalidChars.Contains(c) ? '_' : c).ToArray());

Copilot uses AI. Check for mistakes.

do
{
await Task.Delay(5000);
var statusResp = await client.GetAsync(statusUrl);
Copy link
Preview

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider calling statusResp.EnsureSuccessStatusCode() after the GET request to immediately handle HTTP errors rather than parsing potentially invalid JSON.

Suggested change
var statusResp = await client.GetAsync(statusUrl);
var statusResp = await client.GetAsync(statusUrl);
statusResp.EnsureSuccessStatusCode();

Copilot uses AI. Check for mistakes.

Comment on lines +36 to +38
var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", apiKey);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
Copy link
Preview

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a new HttpClient instance per request can lead to socket exhaustion; consider reusing a single HttpClient instance or using IHttpClientFactory.

Suggested change
var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", apiKey);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var client = httpClient; // Reuse the top-level HttpClient instance

Copilot uses AI. Check for mistakes.

</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="6.0.1" />
Copy link
Preview

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The UserSecrets package version 6.0.1 may not align with the project's .NET 9.0 target; consider updating to a version compatible with .NET 9 or relying on built-in secrets support.

Copilot uses AI. Check for mistakes.

Copy link

github-actions bot commented Jun 3, 2025

Check Broken URLs

We have automatically detected the following broken URLs in your files. Review and fix the paths to resolve this issue.

Check the file paths and associated broken URLs inside them.
For more details, check our Contributing Guide.

File Full Path Issues
README.md
#LinkLine Number
1https://dcbadge.vercel.app/api/server/ByRwuEEgH415
02-SetupDevEnvironment/getting-started-azure-openai.md
#LinkLine Number
1https://learn.microsoft.com/azure/ai-services/deploy/160
translations/de/README.md
#LinkLine Number
1https://dcbadge.vercel.app/api/server/ByRwuEEgH415
translations/de/02-SetupDevEnvironment/getting-started-azure-openai.md
#LinkLine Number
1https://learn.microsoft.com/azure/ai-services/deploy/159
translations/de/03-CoreGenerativeAITechniques/06-AIToolkitAndDockerModels.md
#LinkLine Number
1https://img.youtube.com/vi/1GwmV1PGRjI/0.jpg13
translations/pt/README.md
#LinkLine Number
1https://dcbadge.vercel.app/api/server/ByRwuEEgH415
translations/pt/02-SetupDevEnvironment/getting-started-azure-openai.md
#LinkLine Number
1https://learn.microsoft.com/azure/ai-services/deploy/159
translations/pt/03-CoreGenerativeAITechniques/06-AIToolkitAndDockerModels.md
#LinkLine Number
1https://img.youtube.com/vi/1GwmV1PGRjI/0.jpg9
translations/zh/README.md
#LinkLine Number
1https://dcbadge.vercel.app/api/server/ByRwuEEgH415
translations/zh/02-SetupDevEnvironment/getting-started-azure-openai.md
#LinkLine Number
1https://learn.microsoft.com/azure/ai-services/deploy/159
translations/zh/03-CoreGenerativeAITechniques/06-AIToolkitAndDockerModels.md
#LinkLine Number
1https://img.youtube.com/vi/1GwmV1PGRjI/0.jpg9
translations/tw/README.md
#LinkLine Number
1https://dcbadge.vercel.app/api/server/ByRwuEEgH415
translations/tw/02-SetupDevEnvironment/getting-started-azure-openai.md
#LinkLine Number
1https://learn.microsoft.com/azure/ai-services/deploy/159
translations/tw/03-CoreGenerativeAITechniques/06-AIToolkitAndDockerModels.md
#LinkLine Number
1https://img.youtube.com/vi/1GwmV1PGRjI/0.jpg9
translations/fr/README.md
#LinkLine Number
1https://dcbadge.vercel.app/api/server/ByRwuEEgH415
translations/fr/02-SetupDevEnvironment/getting-started-azure-openai.md
#LinkLine Number
1https://learn.microsoft.com/azure/ai-services/deploy/159
translations/fr/03-CoreGenerativeAITechniques/06-AIToolkitAndDockerModels.md
#LinkLine Number
1https://img.youtube.com/vi/1GwmV1PGRjI/0.jpg9
translations/es/README.md
#LinkLine Number
1https://dcbadge.vercel.app/api/server/ByRwuEEgH415
translations/es/02-SetupDevEnvironment/getting-started-azure-openai.md
#LinkLine Number
1https://learn.microsoft.com/azure/ai-services/deploy/159
translations/es/03-CoreGenerativeAITechniques/06-AIToolkitAndDockerModels.md
#LinkLine Number
1https://img.youtube.com/vi/1GwmV1PGRjI/0.jpg9
translations/ja/README.md
#LinkLine Number
1https://dcbadge.vercel.app/api/server/ByRwuEEgH415
translations/ja/02-SetupDevEnvironment/getting-started-azure-openai.md
#LinkLine Number
1https://learn.microsoft.com/azure/ai-services/deploy/159
translations/ja/03-CoreGenerativeAITechniques/06-AIToolkitAndDockerModels.md
#LinkLine Number
1https://img.youtube.com/vi/1GwmV1PGRjI/0.jpg9
translations/ko/README.md
#LinkLine Number
1https://dcbadge.vercel.app/api/server/ByRwuEEgH415
translations/ko/02-SetupDevEnvironment/getting-started-azure-openai.md
#LinkLine Number
1https://learn.microsoft.com/azure/ai-services/deploy/159
translations/ko/03-CoreGenerativeAITechniques/06-AIToolkitAndDockerModels.md
#LinkLine Number
1https://img.youtube.com/vi/1GwmV1PGRjI/0.jpg9
03-CoreGenerativeAITechniques/05-ImageGenerationOpenAI.md
#LinkLine Number
1https://learn.microsoft.com/azure/ai-services/openai/concepts/understanding-image-generation-responses152
03-CoreGenerativeAITechniques/06-AIToolkitAndDockerModels.md
#LinkLine Number
1https://learn.microsoft.com/windows/ai/toolkit/install28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant