บทช่วยสอน: สร้าง อัปเดต และแสดงรายการการตั้งค่าการจัดการสภาพแวดล้อม (พรีวิว)
[บทความนี้เป็นคู่มือรุ่นก่อนวางจำหน่าย และอาจจะมีการเปลี่ยนแปลงในอนาคต]
บทช่วยสอนนี้สาธิตวิธีใช้ Power Platform API (พรีวิว) เพื่อสร้าง อัปเดต และรายการการตั้งค่าการจัดการสภาพแวดล้อม
ในบทช่วยสอนนี้ เรียนรู้วิธีการ:
- ยืนยันตัวตนโดยใช้ Power Platform API
- สร้างค่าการตั้งค่าใหม่
- แสดงรายการค่าการตั้งค่าการจัดการทั้งหมดสำหรับสภาพแวดล้อม
- อัปเดตค่าการตั้งค่า
ตัวอย่างของสถานการณ์นี้ ลูกค้าอาจต้องการเปิดใช้งาน ข้อจำกัด IP ของลายเซ็นการเข้าถึงที่แชร์ที่เก็บข้อมูล (SAS) และการบันทึกการโทร SAS
สำคัญ
- นี่คือคุณลักษณะพรีวิว
- คุณลักษณะพรีวิวไม่ได้มีไว้สำหรับการนำไปใช้งานจริงและอาจมีฟังก์ชันการทำงานที่จำกัด คุณลักษณะเหล่านี้สามารถใช้ได้ก่อนการเปิดตัวอย่างเป็นทางการ เพื่อให้ลูกค้าสามารถเข้าใช้งานได้ก่อนเวลาและให้ข้อคิดเห็น
ขั้นตอนที่ 1 ตรวจสอบความถูกต้องโดยใช้ Power Platform API
ใช้สคริป PowerShell ต่อไปนี้เพื่อตรวจสอบความถูกต้องโดยใช้ Power Platform API
Import-Module "MSAL.PS"
$AuthResult = Get-MsalToken -ClientId '49676daf-ff23-4aac-adcc-55472d4e2ce0' -Scope 'https://api.powerplatform.com/.default'
$Headers = @{Authorization = "Bearer $($AuthResult.AccessToken)"}
ขั้นตอนที่ 2 สร้างค่าการตั้งค่าใหม่
ใช้สคริปต์ PowerShell ต่อไปนี้เพื่อสร้างค่าการตั้งค่าใหม่สำหรับการจำกัด IP ของ Storage Shared Access Signature (SAS) และความสามารถในการบันทึกการตรวจสอบที่เกี่ยวข้อง การตั้งค่าทั้งสองนี้ปิดอยู่ อย่างไรก็ตาม เราจะอัปเดตเพื่อเปิดในภายหลัง
#Set your environment ID
$environmentId = "ENV_ID_HERE"
# Please uncomment the values that need to be updated
$EnvironmentManagementSettings = @{
"EnableIpBasedStorageAccessSignatureRule" = $false
"LoggingEnabledForIpBasedStorageAccessSignature" = $false
}
$body = $json = $EnvironmentManagementSettings | ConvertTo-Json
try
{
# Create the new setting value
Write-Host "Invoking Create Management Setting for Environment $environmentId with body $body"
$apiResponse = Invoke-WebRequest -Method Post -Uri "https://api.powerplatform.com/environmentmanagement/environments/$environmentId/settings/?api-version=2022-03-01-preview" -Headers $Headers -Body $body
Write-Host "Operation Status: $apiResponse.StatusDescription"
}
catch
{
# Dig into the exception to get the Response details.
Write-Host "Response CorrelationId:" $_.Exception.Response.Headers["x-ms-correlation-id"]
Write-Host "StatusCode:" $_.Exception.Response.StatusCode.value__
Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription
$result = $_.Exception.Response.GetResponseStream()
$reader = New-Object System.IO.StreamReader($result)
$reader.BaseStream.Position = 0
$reader.DiscardBufferedData()
$responseBody = $reader.ReadToEnd();
Write-Host $responseBody
}
เรียนรู้เพิ่มเติมเกี่ยวกับ Power Platform ข้อมูลอ้างอิง API ใน การตั้งค่าการจัดการสภาพแวดล้อม - สร้างการตั้งค่าการจัดการสภาพแวดล้อม
ขั้นตอนที่ 3 รายการการตั้งค่าการจัดการทั้งหมดสำหรับสภาพแวดล้อม
ใช้สคริปต์ PowerShell ต่อไปนี้เพื่อแสดงรายการการตั้งค่าทั้งหมดที่สร้างไว้ก่อนหน้านี้สำหรับสภาพแวดล้อมนี้
#Set your environment ID
$environmentId = "ENV_ID_HERE"
try
{
# Create the new setting value
Write-Host "Invoking List Management Settings for Environment $environmentId"
$apiResponse = Invoke-WebRequest -Method Get -Uri "https://api.powerplatform.com/environmentmanagement/environments/$environmentId/settings/?api-version=2022-03-01-preview&$select=EnableIpBasedStorageAccessSignatureRule,LoggingEnabledForIpBasedStorageAccessSignature" -Headers $Headers
Write-Host $apiResponse
}
catch
{
# Dig into the exception to get the Response details.
Write-Host "Response CorrelationId:" $_.Exception.Response.Headers["x-ms-correlation-id"]
Write-Host "StatusCode:" $_.Exception.Response.StatusCode.value__
Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription
$result = $_.Exception.Response.GetResponseStream()
$reader = New-Object System.IO.StreamReader($result)
$reader.BaseStream.Position = 0
$reader.DiscardBufferedData()
$responseBody = $reader.ReadToEnd();
Write-Host $responseBody
}
เรียนรู้เพิ่มเติมเกี่ยวกับ Power Platform ข้อมูลอ้างอิง API ใน การตั้งค่าการจัดการสภาพแวดล้อม - รายการการตั้งค่าการจัดการสภาพแวดล้อม
ขั้นตอนที่ 4 อัปเดตค่าการตั้งค่า
ใช้สคริปต์ PowerShell ต่อไปนี้เพื่ออัปเดตค่าการตั้งค่าที่กำหนดไว้ก่อนหน้านี้ ใน ขั้นตอน นี้ คุณเปิดการบันทึกสำหรับ Storage Shared Access Signature (SAS)
#Set your environment ID
$environmentId = "ENV_ID_HERE"
# Please uncomment the values that need to be updated
$EnvironmentManagementSettings = @{
"LoggingEnabledForIpBasedStorageAccessSignature" = $true
}
$body = $json = $EnvironmentManagementSettings | ConvertTo-Json
try
{
# Updating the setting value
Write-Host "Invoking Update Management Setting for Environment $environmentId with body $body"
$apiResponse = Invoke-WebRequest -Method Patch -Uri "https://api.powerplatform.com/environmentmanagement/environments/$environmentId/settings/?api-version=2022-03-01-preview" -Headers $Headers -Body $body
Write-Host "Operation Status: $apiResponse.StatusDescription"
}
catch
{
# Dig into the exception to get the Response details.
Write-Host "Response CorrelationId:" $_.Exception.Response.Headers["x-ms-correlation-id"]
Write-Host "StatusCode:" $_.Exception.Response.StatusCode.value__
Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription
$result = $_.Exception.Response.GetResponseStream()
$reader = New-Object System.IO.StreamReader($result)
$reader.BaseStream.Position = 0
$reader.DiscardBufferedData()
$responseBody = $reader.ReadToEnd();
Write-Host $responseBody
}
เรียนรู้เพิ่มเติมเกี่ยวกับ Power Platform ข้อมูลอ้างอิง API ใน การตั้งค่าการจัดการสภาพแวดล้อม - อัปเดตการตั้งค่าการจัดการสภาพแวดล้อม