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

Merged
merged 44 commits into from
Feb 14, 2025
Merged
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
1702f14
Slice 535826: [AI][Public Preview]Copilot Toolkit: Automatic access v…
Nov 12, 2024
09f9d04
Restored SetManagedResourceAuthorization with old parameters
Nov 12, 2024
4119ef8
Removed unnessecary variables when verifying Microsoft managed resour…
Nov 12, 2024
9ed666f
Merge commit '9fc5c8aac7c0c57e78b1f75d0830ee8ea718f9cb' into aoai-acc…
Nov 26, 2024
da93eee
Merge branch 'main' of https://github.com/microsoft/BCApps into aoai-…
christian-andersen-msft Dec 12, 2024
0264589
Merge branch 'main' of https://github.com/microsoft/BCApps into aoai-…
christian-andersen-msft Dec 16, 2024
22af527
Simplified configuration check and made it more flexible
christian-andersen-msft Dec 16, 2024
f9abbb7
Merge branch 'main' into aoai-access-verification-rebranch
christian-andersen-msft Dec 19, 2024
5fc3ec2
Merge branch 'main' into aoai-access-verification-rebranch
christian-andersen-msft Jan 6, 2025
2b18667
Temporary Database and notification templates added
christian-andersen-msft Jan 8, 2025
8a08eb2
tmp template changes
christian-andersen-msft Jan 10, 2025
d6c54fe
Grace period with caching added
christian-andersen-msft Jan 10, 2025
54ad50a
Added notification and telemetry to verification logic as well as reo…
christian-andersen-msft Jan 13, 2025
02bd29c
corercted comments
christian-andersen-msft Jan 13, 2025
16e7169
added debugging messages
christian-andersen-msft Jan 14, 2025
e3680d2
Merge branch 'main' into aoai-access-verification-rebranch
christian-andersen-msft Jan 14, 2025
8c41f6d
removed wrong reference
christian-andersen-msft Jan 14, 2025
10ec3e8
Added execution permissions to table and increased test timeouts
christian-andersen-msft Jan 14, 2025
e6ce450
added additional debugging messages
christian-andersen-msft Jan 15, 2025
b6d0848
Added obsolete to old SetManagedResourceAuthorization, Removed NonDeb…
christian-andersen-msft Jan 15, 2025
91c85c7
Updated debugging messages to handle duration
christian-andersen-msft Jan 16, 2025
8d03c7f
fixed errors in debugging formatting
christian-andersen-msft Jan 17, 2025
efd3c2e
Merge branch 'main' into aoai-access-verification-rebranch
christian-andersen-msft Jan 17, 2025
8f292ec
Merge branch 'main' into aoai-access-verification-rebranch
christian-andersen-msft Jan 21, 2025
b7750b2
Updated quality and functionality of logging messages and user notifi…
christian-andersen-msft Jan 22, 2025
e711ea4
Merge branch 'main' into aoai-access-verification-rebranch
christian-andersen-msft Jan 22, 2025
69ae41a
Notification text improved. Logic regarding grace period updated. Deb…
christian-andersen-msft Jan 23, 2025
a1bf072
Variables sorted alphabetically
christian-andersen-msft Jan 23, 2025
41f99e6
field caption clarified
christian-andersen-msft Jan 23, 2025
2df6e9a
Description of parameters improved
christian-andersen-msft Jan 23, 2025
1d2a760
Added session telemetry
christian-andersen-msft Jan 23, 2025
09e7ac7
Added telemetry tags
christian-andersen-msft Jan 23, 2025
8047054
Implemented suggestions from PR
christian-andersen-msft Feb 7, 2025
9b32e37
Merge branch 'main' into aoai-access-verification-rebranch
christian-andersen-msft Feb 7, 2025
cb7580e
Clean tag moved to the correct procedure
christian-andersen-msft Feb 12, 2025
76ae32e
Validates aoai account name and aoai url before account validation
christian-andersen-msft Feb 12, 2025
9582ffb
Merge branch 'main' into aoai-access-verification-rebranch
christian-andersen-msft Feb 12, 2025
485d1f8
fixed hostname verification
christian-andersen-msft Feb 12, 2025
659f07e
Telemetry tags added
christian-andersen-msft Feb 12, 2025
f17d2c1
Merge branch 'main' into aoai-access-verification-rebranch
christian-andersen-msft Feb 13, 2025
d6fa420
Merge branch 'main' into aoai-access-verification-rebranch
christian-andersen-msft Feb 13, 2025
9c25aea
Merge branch 'main' into aoai-access-verification-rebranch
christian-andersen-msft Feb 14, 2025
cf1f046
Replaced CopilotCapability reference with AzureOpenAI
christian-andersen-msft Feb 14, 2025
a48ce42
added references to URI and Regex
christian-andersen-msft Feb 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Slice 535826: [AI][Public Preview]Copilot Toolkit: Automatic access v…
…erification for AOAI services to develop and run on CAPI/managed AI resources
Christian Andersen committed Nov 26, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 1702f14ac06699cf409389359b0b1f3cabe6d0f6
Original file line number Diff line number Diff line change
@@ -48,15 +48,19 @@ codeunit 7767 "AOAI Authorization"
end;

[NonDebuggable]
procedure SetMicrosoftManagedAuthorization(NewEndpoint: Text; NewDeployment: Text; NewApiKey: SecretText; NewManagedResourceDeployment: Text)
procedure SetMicrosoftManagedAuthorization(AOAIAccountName: Text; NewApiKey: SecretText; NewManagedResourceDeployment: Text)
var
IsVerified: Boolean;
begin
ClearVariables();
IsVerified := VerifyAOAIAccount(AOAIAccountName, NewApiKey.Unwrap());

ResourceUtilization := Enum::"AOAI Resource Utilization"::"Microsoft Managed";
Endpoint := NewEndpoint;
Deployment := NewDeployment;
ApiKey := NewApiKey;
ManagedResourceDeployment := NewManagedResourceDeployment;
if IsVerified then begin
ResourceUtilization := Enum::"AOAI Resource Utilization"::"Microsoft Managed";
Endpoint := "endpoint";//NewEndpoint;
ApiKey := NewApiKey;
ManagedResourceDeployment := NewManagedResourceDeployment;
end;
end;

[NonDebuggable]
@@ -116,4 +120,37 @@ codeunit 7767 "AOAI Authorization"
Clear(ManagedResourceDeployment);
Clear(ResourceUtilization);
end;

local procedure VerifyAOAIAccount(AOAIAccountName: Text; NewApiKey: Text): Boolean
var
HttpClient: HttpClient;
HttpRequestMessage: HttpRequestMessage;
HttpResponseMessage: HttpResponseMessage;
HttpContent: HttpContent;
ContentHeaders: HttpHeaders;
Url: Text;
IsSuccessful: Boolean;
begin
Url := 'https://' + AOAIAccountName + '.openai.azure.com/openai/models?api-version=2024-06-01';

HttpContent.GetHeaders(ContentHeaders);
if ContentHeaders.Contains('Content-Type') then
ContentHeaders.Remove('Content-Type');
ContentHeaders.Add('Content-Type', 'application/json');
ContentHeaders.Add('api-key', NewApiKey);

HttpRequestMessage.Method := 'GET';
HttpRequestMessage.SetRequestUri(Url);
HttpRequestMessage.Content(HttpContent);

IsSuccessful := HttpClient.Send(HttpRequestMessage, HttpResponseMessage);

if not IsSuccessful then
exit(false);

if not HttpResponseMessage.IsSuccessStatusCode() then
exit(false);

exit(true);
end;
}
Original file line number Diff line number Diff line change
@@ -91,18 +91,13 @@ codeunit 7771 "Azure OpenAI"
/// 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="Endpoint">The endpoint to use to verify access to Azure OpenAI. This is used only for verification, not for actual Azure OpenAI calls.</param>
/// <param name="Deployment">The deployment to use to verify access to Azure OpenAI. This is used only for verification, not for actual Azure OpenAI calls.</param>
/// <param name="AOAIAccountName">Azure OpenAI account name)</param>
/// <param name="ApiKey">The API key to use to verify access to Azure OpenAI. This is used only for verification, not for actual Azure OpenAI calls.</param>
/// <param name="ManagedResourceDeployment">The managed deployment to use for the model type.</param>
/// <remarks> NOTE: This function is currently only available to selected partners.
/// Endpoint would look like: https://resource-name.openai.azure.com/
/// Deployment would look like: gpt-35-turbo-16k
/// </remarks>
[NonDebuggable]
procedure SetManagedResourceAuthorization(ModelType: Enum "AOAI Model Type"; Endpoint: Text; Deployment: Text; ApiKey: SecretText; ManagedResourceDeployment: Text)
procedure SetManagedResourceAuthorization(ModelType: Enum "AOAI Model Type"; AOAIAccountName: Text; ApiKey: SecretText; ManagedResourceDeployment: Text)
begin
AzureOpenAIImpl.SetManagedResourceAuthorization(ModelType, Endpoint, Deployment, ApiKey, ManagedResourceDeployment);
AzureOpenAIImpl.SetManagedResourceAuthorization(ModelType, AOAIAccountName, ApiKey, ManagedResourceDeployment);
end;

/// <summary>
Original file line number Diff line number Diff line change
@@ -188,15 +188,15 @@ codeunit 7772 "Azure OpenAI Impl"
end;

[NonDebuggable]
procedure SetManagedResourceAuthorization(ModelType: Enum "AOAI Model Type"; Endpoint: Text; Deployment: Text; ApiKey: SecretText; ManagedResourceDeployment: Text)
procedure SetManagedResourceAuthorization(ModelType: Enum "AOAI Model Type"; AOAIAccountName: Text; ApiKey: SecretText; ManagedResourceDeployment: Text)
begin
case ModelType of
Enum::"AOAI Model Type"::"Text Completions":
TextCompletionsAOAIAuthorization.SetMicrosoftManagedAuthorization(Endpoint, Deployment, ApiKey, ManagedResourceDeployment);
TextCompletionsAOAIAuthorization.SetMicrosoftManagedAuthorization(AOAIAccountName, ApiKey, ManagedResourceDeployment);
Enum::"AOAI Model Type"::Embeddings:
EmbeddingsAOAIAuthorization.SetMicrosoftManagedAuthorization(Endpoint, Deployment, ApiKey, ManagedResourceDeployment);
EmbeddingsAOAIAuthorization.SetMicrosoftManagedAuthorization(AOAIAccountName, ApiKey, ManagedResourceDeployment);
Enum::"AOAI Model Type"::"Chat Completions":
ChatCompletionsAOAIAuthorization.SetMicrosoftManagedAuthorization(Endpoint, Deployment, ApiKey, ManagedResourceDeployment);
ChatCompletionsAOAIAuthorization.SetMicrosoftManagedAuthorization(AOAIAccountName, ApiKey, ManagedResourceDeployment);
else
Error(InvalidModelTypeErr);
end;