_posts/2018-09-14-functions-appservice-auth.html [335:411]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Bearer トークン
$bearerToken = $authResult.Result.CreateAuthorizationHeader()
### Function の呼び出し###
# Function の URL
$functionUri = "https://jpcieauthtest.azurewebsites.net/api/HttpTriggerCSharp1?code=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# 要求 Body
$body="{'name': 'Azure'}"
# HTTP 要求ヘッダの Authorization ヘッダに Bearerトークンを設定
$requestHeader = @{
"Authorization" = $bearerToken
}
# HTTPS のセキュリティ プロトコルを TLS 1.2 に設定
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# Function に HTTP 要求を送信
try{
$response = Invoke-RestMethod -Uri $functionUri -Method Post -Headers $requestHeader -Body $body -ContentType "application/json"
echo $response
}catch{
Write-Error($_.Exception);
}
[/powershell]
[C#]
[csharp]
/* Azure AD テナントの設定 */
// Azure AD テナントのディレクトリ ID
string adId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
// トークン発行元
string authority = "https://login.microsoftonline.com/" + adId;
/* Function App で作成した AD アプリ */
// クライアント ID
string resourceApplicationId = "11f15836-8e45-4fb9-b9f8-b66611b21f8b";
/* クライアント用に作成した AD アプリ */
// アプリケーション ID
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_posts/2018-09-14-functions-appservice-auth.html [551:627]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Bearer トークン
$bearerToken = $authResult.Result.CreateAuthorizationHeader()
### Function の呼び出し###
# Function の URL
$functionUri = "https://jpcieauthtest.azurewebsites.net/api/HttpTriggerCSharp1?code=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# 要求 Body
$body="{'name': 'Azure'}"
# HTTP 要求ヘッダの Authorization ヘッダに Bearerトークンを設定
$requestHeader = @{
"Authorization" = $bearerToken
}
# HTTPS のセキュリティ プロトコルを TLS 1.2 に設定
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# Function に HTTP 要求を送信
try{
$response = Invoke-RestMethod -Uri $functionUri -Method Post -Headers $requestHeader -Body $body -ContentType "application/json"
echo $response
}catch{
Write-Error($_.Exception);
}
[/powershell]
[C#]
[csharp]
/* Azure AD テナントの設定 */
// Azure AD テナントのディレクトリ ID
string adId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
// トークン発行元
string authority = "https://login.microsoftonline.com/" + adId;
/* Function App で作成した AD アプリ */
// クライアント ID
string resourceApplicationId = "11f15836-8e45-4fb9-b9f8-b66611b21f8b";
/* クライアント用に作成した AD アプリ */
// アプリケーション ID
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -