Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Hướng dẫn này trình bày cách sử dụng Power Platform API (bản xem trước) để tạo, cập nhật và liệt kê Cài đặt quản lý môi trường.
Trong hướng dẫn này, hãy tìm hiểu cách:
- Xác thực bằng API Power Platform .
- Tạo giá trị cài đặt mới.
- Liệt kê tất cả các giá trị cài đặt quản lý cho môi trường.
- Cập nhật giá trị cài đặt.
Ví dụ về trường hợp này, khách hàng có thể muốn bật hạn chế IP Chữ ký Truy nhập Chung Lưu trữ (SAS) và ghi nhật ký cuộc gọi SAS.
Bước 1. Xác thực bằng cách sử dụng Power Platform API
Sử dụng tập lệnh PowerShell sau để xác thực bằng Power Platform API.
Import-Module "MSAL.PS"
$AuthResult = Get-MsalToken -ClientId '<client id of your Microsoft Entra ID application registration>' -Scope 'https://api.powerplatform.com/.default'
$Headers = @{Authorization = "Bearer $($AuthResult.AccessToken)"}
Bước 2. Tạo giá trị cài đặt mới
Sử dụng tập lệnh PowerShell sau đây để tạo giá trị thiết đặt mới cho các hạn chế IP Chữ ký Truy nhập Chia sẻ Lưu trữ (SAS) và khả năng ghi nhật ký kiểm tra liên quan. Hai cài đặt này đã tắt nhưng chúng tôi sẽ cập nhật chúng sau để bật.
#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
}
Tìm hiểu thêm về Power Platform tham chiếu API trong Cài đặt quản lý môi trường - Tạo cài đặt quản lý môi trường.
Bước 3. Liệt kê tất cả các thiết lập quản lý cho môi trường
Sử dụng tập lệnh PowerShell sau để liệt kê tất cả các cài đặt đã tạo trước đó cho môi trường này.
#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
}
Tìm hiểu thêm về Power Platform tham chiếu API trong Cài đặt quản lý môi trường - Liệt kê cài đặt quản lý môi trường.
Bước 4. Cập nhật giá trị cài đặt
Sử dụng tập lệnh PowerShell sau để cập nhật giá trị cài đặt đã xác định trước đó. Trong bước này, bạn bật tính năng ghi nhật ký cho Chữ ký truy cập chia sẻ lưu trữ (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
}
Tìm hiểu thêm về Power Platform tham chiếu API trong Cài đặt quản lý môi trường - Cập nhật cài đặt quản lý môi trường.