-
Notifications
You must be signed in to change notification settings - Fork 1
Adding authentication samples Java #46
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 |
samples/authentication-key-credential/java/sample.java.template
Outdated
Show resolved
Hide resolved
<%= java.valueOrEnvironment(useEnvVars, "endpoint", "AZURE_OPENAI_ENDPOINT", endpoint)%> | ||
<%= java.valueOrEnvironment(useEnvVars, "deploymentName", "AZURE_OPENAI_DEPLOYMENT", deploymentName)%> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could combine this template with the other and add a conditional on the auth type.
e.g.
https://github.com/Azure-Samples/template-samples/blob/main/samples/chat-completion/csharp/sample.cs.template
and
https://github.com/Azure-Samples/template-samples/pull/28/files
There was a problem hiding this comment.
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?)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
I ran the Also had to |
v1
endpoint usage in the sample?.gitignore