Skip to content
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

Automatic access verification for AOAI services to develop and run on CAPI/managed AI resources #2764

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

christian-andersen-msft
Copy link
Contributor

@christian-andersen-msft christian-andersen-msft commented Jan 14, 2025

Fixes AB#535826

@christian-andersen-msft christian-andersen-msft requested a review from a team as a code owner January 14, 2025 12:31
@christian-andersen-msft christian-andersen-msft changed the title Aoai access verification rebranch Automatic access verification for AOAI services to develop and run on CAPI/managed AI resources Jan 14, 2025
@github-actions github-actions bot added this to the Version 26.0 milestone Jan 14, 2025
/// This will send the Azure OpenAI call to the deployment specified in <paramref name="ManagedResourceDeployment"/>, and will use the other parameters to verify that you have access to Azure OpenAI.
/// </summary>
/// <param name="ModelType">The model type to set authorization for.</param>
/// <param name="AOAIAccountName">Azure OpenAI account name)</param>
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: In case of parameters that are not super obvious, I like to add a sample of how they look like in the documentation comment. For example here you could do: An Azure OpenAI account name. For example, if your Azure OpenAI endpoint is "contoso.openai.azure.com", use "contoso" for this parameter.

end;

[NonDebuggable]
procedure SetMicrosoftManagedAuthorization(AOAIAccountName: Text; NewApiKey: SecretText; NewManagedResourceDeployment: Text)
Copy link
Contributor

Choose a reason for hiding this comment

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

Mmmm I suggest we keep the pattern that this file was using before (=> the Set... functions are just setting values, and then we check that the values are valid inside IsConfigured).

This saves us from possible bugs if some other part of the code is changing the authorization variables (and also delays checking the access and the validity of the values until they are actually needed).

Which means, here you just need to set the values for RecourceUtilization, ManagedResourceDeployment, and AOAIAccountName to some global variable. And then you can move the call to VerifyAOAIAccount to inside IsConfigured instead, and you don't need the three boolean variables.

TruncatedAccountName := CopyStr(AOAIAccountName, 1, 100);

if IsAccountVerifiedWithinPeriod(TruncatedAccountName, CachePeriod) then begin
Message('Verification skipped (within cache period).');
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess messages here are also for testing purposes. I think it's still a good idea to log this to telemetry though, so later you can add some Session.LogMessage instead of the Messages.

ContentHeaders: HttpHeaders;
Url: Text;
IsSuccessful: Boolean;
UrlFormatTxt: Label 'https://%1.openai.azure.com/openai/models?api-version=2024-06-01', Locked = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to handle this part of the request in platform? We handle other things there like ensuring the calls are aligned on api-version (I know we spoke about this previously so just wondering if there was a better reason for doing this in sys app)

Now we will have to remember to maintain both app and platform when moving to a newer api-version (and in app we would have to HF all minor releases).

Additionally, the verification log could be a system table so all the tracking and gating could be handled there

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.

4 participants