Skip to content

Conversation

jpalvarezl
Copy link
Collaborator

@jpalvarezl jpalvarezl commented Jul 29, 2025

  • Adding entraID and key authentication samples for Java
  • WIP: how to showcase v1 endpoint usage in the sample?
  • Updates to .gitignore

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 Java authentication samples for Azure OpenAI, implementing both Entra ID and API key credential authentication methods. The samples demonstrate how to authenticate and make chat completion requests using different credential types.

  • Adds Entra ID authentication sample using DefaultAzureCredential and BearerTokenCredential
  • Adds API key authentication sample using AzureApiKeyCredential
  • Configures sample generation in input-data.yaml to include both new authentication samples

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
samples/input-data.yaml Adds configuration for generating both authentication samples
samples/authentication-key-credential/java/sample.yaml Defines metadata and dependencies for API key authentication sample
samples/authentication-key-credential/java/sample.java.template Implements API key authentication example with chat completion
samples/authentication-entra-id/java/sample.yaml Defines metadata and dependencies for Entra ID authentication sample
samples/authentication-entra-id/java/sample.java.template Implements Entra ID authentication example with chat completion

Comment on lines +12 to +13
<%= java.valueOrEnvironment(useEnvVars, "endpoint", "AZURE_OPENAI_ENDPOINT", endpoint)%>
<%= java.valueOrEnvironment(useEnvVars, "deploymentName", "AZURE_OPENAI_DEPLOYMENT", deploymentName)%>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

(Which maybe is a tradeoff of readability vs reduced surface area?)

Copy link
Collaborator Author

@jpalvarezl jpalvarezl Jul 30, 2025

Choose a reason for hiding this comment

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

That's what felt kind of weird about adding these samples, but rather than exercising ChatCompletions I want to draw attention to the authentication type. But they are totally redundant and in fact could be compacted into a single sample, like the one you shared.

Not entirely sure how this will be surfaced in the Foundry website, we might not even need samples showcasing authentication specifically 🤔 Happy to close the PR without merging.

Copy link
Collaborator

Choose a reason for hiding this comment

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

my mistake! Even though the PR title says as much, I didn't pick up on the intention to focus on auth. I think it's totally founded to have a sample that targets auth.

These are firstly to provide SDK coverage, then hopefully secondarily provide useful to partners (like Foundry or Docs teams). So no worries on adding things that Foundry or other doesn't use.

@jpalvarezl
Copy link
Collaborator Author

I ran the che batch samples/input-data.yaml command and it pushed even csharp generated samples. Is this expected? I would guess that we should probably have the generate-samples folder added to the .gitignore list 🤔

Also had to chmod +x the scripts so the PR change set got a bit out of hand.

@jpalvarezl jpalvarezl marked this pull request as ready for review August 12, 2025 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants