Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit604b59e

Browse files
committed
simple aoai powershell call
1 parent81c094f commit604b59e

File tree

4 files changed

+80
-43
lines changed

4 files changed

+80
-43
lines changed

‎_drafts/2021-05-XX-build-a-WVD-playground-for-Demos.md‎

Lines changed: 0 additions & 36 deletions
This file was deleted.

‎_drafts/apim/00-organize-aoai-instances-with-apim.md‎

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ header:
99
caption:"Photo credit: [**nicola since 1972**](https://www.flickr.com/photos/15216811@N06/52755090506)"
1010
---
1111

12-
In this blog post, I propose an approach based on Azure API Manager for the management, monitoring, and reporting of Azure Open AI deployment instances within an enterprise.
13-
1412
Azure OpenAI Service provides REST API access to OpenAI's powerful language models including o1, o1-mini, GPT-4o, GPT-4o mini, GPT-4 Turbo with Vision, GPT-4, GPT-3.5-Turbo, and Embeddings model series. These models can be easily adapted to your specific task including but not limited to content generation, summarization, image understanding, semantic search, and natural language to code translation.
1513

1614
Azure API Management, on the other hand, is a comprehensive API management platform that helps enterprises manage, secure, and monitor their APIs. It provides features such as API gateway, rate limiting, analytics, and developer portal, making it easier for businesses to expose their services to internal and external consumers.
@@ -21,27 +19,63 @@ Combining Azure Open AI with Azure API Manager enables enterprises to efficientl
2119

2220
----------------------------
2321

24-
obiettivo di questa serie di post é quello di mostrate alcuni dei pattern da usare per esporre Azure Open AI attraverso APIM
22+
obiettivo di questa serie di post é quello di mostrate alcuni dei pattern da usare per esporre Azure Open AI attraverso APIM.
23+
24+
In this context, the following architecturea and implementation in Azure Architecture Center are**developed** and**maintained** by Azure Pattern and Practices team. I suggest yout to bookmark them for further information.
25+
26+
*https://learn.microsoft.com/en-us/azure/architecture/ai-ml/architecture/azure-openai-baseline-landing-zone
27+
*https://github.com/Azure-Samples/azure-openai-chat-baseline-landing-zone
2528

26-
il laboratorio su cui lavoreremo prevede le seguenti risorse:
29+
in questi post ci focalizzeremo sulla configurazione delle policy e di implementazione di alcuni pattern di utilizzo con esse. La parte di configurazione della rete e l'integrazione con una ESLZ é out of scope. Per un walktrough che guidi l'integrazione di APIM ed AOAI in un contesto di hub & spoke, è possibile fare riferimento anche[al mio articolo](https://github.com/nicolgit/hub-and-spoke-playground/blob/main/scenarios/aoai.md) disponibile nell'ambito del progetto[the hub-and-spoke playground](https://github.com/nicolgit/hub-and-spoke-playground)
30+
31+
32+
Il laboratorio su cui lavoró prevede le seguenti risorse:
2733

2834
* Azure API Management service (developer SKU) enterpriseapim
2935
* 2 x Azure OpenAI service (S0 SKU) apimaoai01 and apimaoai02
3036

37+
come mostrato nello schema seguente:
38+
39+
«««««««««««««««««««««««««««««««« ARCHITETTURA SUPER SEMPLICE »»»»»»»»»»»»»»»»»»»»»»»»»»»»»
3140

41+
#01 Add Azure open AI as backend resource
3242

43+
Go to API Management services >`nicold-apim` > Backends > Add
44+
* Name:`apim-001`
45+
* Backend hosting type: Custom URL
46+
* Runtime URL:https://nicold-aoai-001.openai.azure.com
47+
* Authorization credential
48+
* Headers
49+
* Name:`api-key`
50+
* Key:_your endpoint key_
51+
* click[create]
3352

34-
in questi post ci focalizzeremo sulla configurazione delle policy e di implementazione di pattern con esse. La parte di configurazione della rete e l'integrazione con una ESLZ é out of scope. Per un walktrough che guidi l'integrazione di APIM ed AOAI in un contesto di hub & spoke, vi rimando[al mio articolo](https://github.com/nicolgit/hub-and-spoke-playground/blob/main/scenarios/aoai.md) disponibile nell'ambito del progetto[the hub-and-spoke playground](https://github.com/nicolgit/hub-and-spoke-playground)
53+
Go to API Management services >`nicold-apim` > Backends > Add
54+
* Name:`apim-002`
55+
* Backend hosting type: Custom URL
56+
* Runtime URL:https://nicold-aoai-002.openai.azure.com
57+
* Authorization credential
58+
* Headers
59+
* Name:`api-key`
60+
* Key:_your endpoint key_
61+
* click[create]
62+
63+
here the result:
64+
![backend resorces added](../../assets/post/2025/apim-aoai/01-add-backend-resources.png)
65+
66+
#02
3567

3668

37-
- add an open ai instance as APIM backend
38-
(aggiunge 2 istanze di apim come backend)
3969
- esporre una API attraverso policy
4070
- livello root
4171
- in /aoai (2 instance) (instance/deployment...)
4272

4373

4474

75+
76+
77+
(forse questi non servono più)
78+
4579
#More information
4680
* Azure Open AI Services:<https://learn.microsoft.com/en-us/azure/ai-services/openai/overview>
4781
* Azure API Management:<https://learn.microsoft.com/en-us/azure/api-management/api-management-key-concepts>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title:Azure OpenAI powershell chat-completition call sample
3+
date:2025-02-24 10:00
4+
tags:[Azure, powershell, OpenAI ]
5+
excerpt:"sample to copy and paste"
6+
7+
header:
8+
overlay_image:https://live.staticflickr.com/65535/52755090506_6cf0808a3c_h.jpg
9+
caption:"Photo credit: [**nicola since 1972**](https://www.flickr.com/photos/15216811@N06/52755090506)"
10+
---
11+
12+
The following powershell samples shows how to call an Azure OpenAI chat completition endpoint API
13+
14+
```
15+
# Azure OpenAI metadata variables
16+
$openai = @{
17+
api_key = "YOUR_APIKEY_HERE"
18+
api_base = "https://your-enpoint-here.openai.azure.com/" # your endpoint
19+
api_version = '2024-02-01'
20+
name = 'your-deployment-name-here' # custom name you chose for your deployment
21+
}
22+
23+
$body = '{
24+
"messages": [
25+
{ "role": "system","content": "You are a helpful assistant."},
26+
{ "role": "user", "content": "Tell me a joke!"}
27+
]}'
28+
29+
# Header for authentication
30+
$headers = [ordered]@{
31+
'api-key' = $openai.api_key
32+
}
33+
34+
# Send a request to generate an answer
35+
$url = "$($openai.api_base)/openai/deployments/$($openai.name)/chat/completions?api-version=$($openai.api_version)"
36+
$response = IRM -Uri $url -Headers $headers -Body $body -Method Post -ContentType 'application/json'
37+
$response.choices.message.content
38+
39+
```
37 KB
Loading

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp