튜토리얼: 환경 관리 설정 생성, 업데이트 및 나열(프리뷰)

[이 문서는 시험판 문서이며 변경될 수 있습니다.]

이 튜토리얼에서는 Power Platform API (프리뷰)를 사용하여 환경 관리 설정을 생성, 업데이트, 나열하는 방법을 보여줍니다.

이 자습서에서는 다음 작업을 수행하는 방법을 알아봅니다.

  1. Power Platform API를 사용하여 인증합니다.
  2. 새로운 설정 값을 만듭니다.
  3. 환경에 대한 모든 관리 설정 값을 나열합니다.
  4. 설정 값을 업데이트합니다.

이 시나리오의 예로, 고객은 SAS(Storage Shared Access Signature) IP 제한 과 SAS 통화 로깅을 켜고 싶어할 수 있습니다.

중요

  • 이는 프리뷰 기능입니다.
  • 프리뷰 기능은 생산용으로 만들어진 것이 아니므로 기능이 제한될 수 있습니다. 이런 기능은 공식 릴리스 전에 사용할 수 있으므로 고객이 조기에 액세스하고 피드백을 제공할 수 있습니다.

1단계. Power Platform API를 사용하여 인증

Power Platform API를 사용하여 인증하려면 다음 PowerShell 스크립트를 사용하세요.

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 스크립트를 사용하여 저장소 공유 액세스 서명(SAS) IP 제한 및 관련 감사 로깅 기능에 대한 새 설정 값을 만듭니다. 이 두 가지 설정은 꺼져 있지만 나중에 업데이트하여 켜도록 하겠습니다.

#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 스크립트를 사용하여 이전에 정의된 설정 값을 업데이트합니다. 이 단계에서는 SAS(Storage Shared Access Signature)에 대한 로깅을 켭니다.

#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 참조에 대해 자세히 알아보려면 환경 관리 설정 - 환경 관리 설정 업데이트를 참조하세요.

환경 관리 설정