Azure AI Foundry: Public Access Connectivity and Function Testing

Azure AI Foundry: Public Access Connectivity and Function Testing
Photo by Phil Huang@Friend's rabbit, Taiwan
Azure AI Foundry: The unified AI Platform
Welcome to the Azure AI Foundry Blog! | Azure AI Foundry Blog
Explore the Azure AI Foundry Blog—your essential resource for learning how to build, customize, and scale AI solutions securely and efficiently with Azure AI Foundry.

Azure AI Foundry consolidates Azure's scattered AI service into a cohesive whole, reducing developmnet complexity. Addtionally, whether or not you choose to use private endpoints will affect the URL of the API Endpoint

Here, I will demostrate using the real Azure AI Foundry API.

aif-pichuang-jpe
https://aif-pichuang-jpe.service.ai.azure.com

Verfication Function via Public Access

Overview of Azure OpenAI

Azure OpenAI: Language APIs

#!/bin/bash
ENDPOINT="https://aif-pichuang-jpe.openai.azure.com/"
AZURE_REGION="japaneast"
AZURE_SUBSCRIPTION_KEY="pichuangishandsome"

# Check Private IP
dig +short aif-pichuang-jpe.openai.azure.com

curl -X POST "${ENDPOINT}/language/:analyze-text?api-version=2022-05-01" \
-H "Ocp-Apim-Subscription-Key: $AZURE_SUBSCRIPTION_KEY" \
-H "Content-Type: application/json" \
-d '{
    "kind": "LanguageDetection",
    "parameters": {
        "modelVersion": "latest"
    },
    "analysisInput":{
        "documents":[
            {
                "id":"1",
                "text": "小飛機 is an CNCF ambassador, he is a senior cloud solution architect at Microsoft Taiwan."
            },
            {
                "id":"2",
                "text": "Phil Huang 是一位台灣微軟架構師,專注於如何通靈"
            }
        ]
    }
}'

Azure OpenAI: Document Intelligence

#!/bin/bash
ENDPOINT="https://aif-pichuang-jpe.openai.azure.com"
AZURE_REGION="japaneast"
AZURE_SUBSCRIPTION_KEY="pichuangishandsome"

response_headers=$(mktemp)
http_status=$(curl -s -D "${response_headers}" -o /dev/null -w "%{http_code}" -X POST \
  "${ENDPOINT}/documentintelligence/documentModels/prebuilt-layout:analyze?api-version=2024-07-31-preview" \
  -H "Content-Type: application/json" \
  -H "Ocp-Apim-Subscription-Key: ${AZURE_SUBSCRIPTION_KEY}" \
  --data-ascii '{"urlSource": "https://transflow.tw/wp-content/uploads/2025/04/IMG_1748-scaled.jpg"}')

echo "HTTP Status Code: ${http_status}"
echo "HTTP Response Header: $(cat ${response_headers})"

location=$(grep -i "^operation-location:" "${response_headers}" | awk '{print $2}' | tr -d '\r\n')
analyze_id=$(echo "${location}" | grep -oE '[0-9a-fA-F-]{8}-[0-9a-fA-F-]{4}-[0-9a-fA-F-]{4}-[0-9a-fA-F-]{4}-[0-9a-fA-F-]{12}')

echo "Analyze ID: ${analyze_id}"
echo "Waiting for analysis to complete after 10 seconds..."
sleep 10

rm -f "${response_headers}"

# Put analyze result
curl -i -X GET \
-H "Ocp-Apim-Subscription-Key: ${AZURE_SUBSCRIPTION_KEY}" \
"${ENDPOINT}/documentintelligence/documentModels/prebuilt-layout/analyzeResults/${analyze_id}?api-version=2024-07-31-preview"
Document Intelligence: HTTP Status Code 202
Document Intelligence: HTTP Status Code 200

Azure OpenAI: Whisper APIs

Need to deploy Whisper Model before testing

Azure OpenAI: Dall-e APIs

Need to deploy Dall-e Model before testing


Overview of Speech APIs

List of Voice

#!/bin/bash
AZURE_REGION="japaneast"
AZURE_SUBSCRIPTION_KEY="pichuangishandsome"

curl --location --request GET "https://${AZURE_REGION}.tts.speech.microsoft.com/cognitiveservices/voices/list" \
--header "Ocp-Apim-Subscription-Key: ${AZURE_SUBSCRIPTION_KEY}"

Speech API: Text to Speech (Neural)

#!/bin/bash
AZURE_REGION="japaneast"
AZURE_SUBSCRIPTION_KEY="pichuangishandsome"
OUTPUT_FILENAME="test_audio.wav"
TOKEN_FILENAME="token.txt"

curl -X POST \
  "https://${AZURE_REGION}.api.cognitive.microsoft.com/sts/v1.0/issueToken" \
  -H "Ocp-Apim-Subscription-Key: $AZURE_SUBSCRIPTION_KEY" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -H "Content-Length: 0" > ${TOKEN_FILENAME}

# echo "Access token: $(cat $TOKEN_FILENAME)"

curl -X POST \
  "https://${AZURE_REGION}.tts.speech.microsoft.com/cognitiveservices/v1" \
  -H "Authorization: Bearer $(cat ${TOKEN_FILENAME})" \
  -H "Content-Type: application/ssml+xml" \
  -H "X-Microsoft-OutputFormat: riff-24khz-16bit-mono-pcm" \
  -d '<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="zh-TW">
        <voice name="zh-TW-HsiaoChenNeural">
          Hello, this is a test message. Phil Huang is happy to be here.
          This is a health check for Azure Text-to-Speech service.
        </voice>
      </speak>' \
  --output ${OUTPUT_FILENAME}

file ${OUTPUT_FILENAME}
Text to Speech

Speech API: Speech to Text

#!/bin/bash
AZURE_REGION="japaneast"
AZURE_SUBSCRIPTION_KEY="pichuangishandsome"
OUTPUT_FILENAME="test_audio.wav"

curl --location --request POST "https://${AZURE_REGION}.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?language=en-US&format=detailed" \
--header "Ocp-Apim-Subscription-Key: $AZURE_SUBSCRIPTION_KEY" \
--header "Content-Type: audio/wav; codecs=audio/pcm; samplerate=16000" \
--data-binary "@$OUTPUT_FILENAME"
Speech to Text

Speech API: Custom Voice

WIP


Overview of Translator APIs

Translator API: Text Translation

#!/bin/bash
ENDPOINT_TRANSLATOR="https://api.cognitive.microsofttranslator.com/translate?api-version=3.0"
TO_LANG="zh-Hant"
TO_LANG_2="ja"
AZURE_REGION="japaneast"
AZURE_SUBSCRIPTION_KEY="pichuangishandsome"
TEXT="Currently testing Azure Translator. If you see this line, it means it was successful. Phil Huang is a very busy cloud architect at Microsoft"

curl -X POST "${ENDPOINT_TRANSLATOR}&to=${TO_LANG}&to=${TO_LANG_2}" -H "Ocp-Apim-Subscription-Key: ${AZURE_SUBSCRIPTION_KEY}" -H "Ocp-Apim-Subscription-Region: ${AZURE_REGION}" -H "Content-Type: application/json; charset=UTF-8" -d "[{'Text':'${TEXT}'}]"; echo
Text Translation

Translator API: Document Translation

#!/bin/bash

ENDPOINT_DOCUMENT_TRANSLATOR="https://aif-pichuang-jpe.cognitiveservices.azure.com/translator/text/v3.0/translate?api-version=3.0"
AZURE_SUBSCRIPTION_KEY="pichuangishandsome"
FROM_LANG="en"
TO_LANG="zh-Hant"
TEXT="Currently testing Azure Translator. If you see this line, it means it was successful"

curl -X POST "$ENDPOINT_DOCUMENT_TRANSLATOR&from=$FROM_LANG&to=$TO_LANG" -H "Ocp-Apim-Subscription-Key: $AZURE_SUBSCRIPTION_KEY" -H "Content-Type: application/json" -d "[{'Text':'$TEXT'}]"; echo
Document Translation