

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 將 UI 從 Studio Classic 遷移至 Studio
<a name="studio-updated-migrate-ui"></a>

遷移現有網域的第一個階段涉及將 UI 從 Amazon SageMaker Studio Classic 遷移至 Amazon SageMaker Studio。此階段不包含資料遷移。使用者可以繼續以與遷移之前相同的方式使用資料。如需遷移資料的相關資訊，請參閱[(選用) 將資料從 Studio Classic 遷移至 Studio](studio-updated-migrate-data.md)。

階段 1 包含下列步驟：

1. 更新 Studio 中可用之新應用程式的應用程式建立許可。

1. 更新網域的 VPC 組態。

1. 升級網域以使用 Studio UI。

## 先決條件
<a name="studio-updated-migrate-ui-prereq"></a>

在執行這些步驟之前，請完成 [完成先決條件以遷移 Studio 體驗](studio-updated-migrate-prereq.md) 中的先決條件。

## 步驟 1：更新應用程式建立許可
<a name="studio-updated-migrate-limit-apps"></a>

在遷移網域之前，請更新網域的執行角色，以授與使用者建立應用程式的許可。

1. 遵循建立 IAM AWS Identity and Access Management 政策中的步驟，使用下列其中一個內容建立 政策： [https://docs.aws.amazon.com//IAM/latest/UserGuide/access_policies_create.html](https://docs.aws.amazon.com//IAM/latest/UserGuide/access_policies_create.html) 
   + 使用下列政策授與所有應用程式類型和空間的許可。
**注意**  
如果網域使用 `SageMakerFullAccess` 政策，您不需要執行此動作。`SageMakerFullAccess` 會授與建立所有應用程式的許可。

------
#### [ JSON ]

****  

     ```
     {
         "Version":"2012-10-17",		 	 	 
         "Statement": [
             {
                 "Sid": "SMStudioUserProfileAppPermissionsCreateAndDelete",
                 "Effect": "Allow",
                 "Action": [
                     "sagemaker:CreateApp",
                     "sagemaker:DeleteApp"
                 ],
                 "Resource": "arn:aws:sagemaker:{{us-east-1}}:{{111122223333}}:app/*",
                 "Condition": {
                     "Null": {
                         "sagemaker:OwnerUserProfileArn": "true"
                     }
                 }
             },
             {
                 "Sid": "SMStudioCreatePresignedDomainUrlForUserProfile",
                 "Effect": "Allow",
                 "Action": [
                     "sagemaker:CreatePresignedDomainUrl"
                 ],
                 "Resource": "arn:aws:sagemaker:{{us-east-1}}:{{111122223333}}:user-profile/${sagemaker:DomainId}/${sagemaker:UserProfileName}"
             },
             {
                 "Sid": "SMStudioAppPermissionsListAndDescribe",
                 "Effect": "Allow",
                 "Action": [
                     "sagemaker:ListApps",
                     "sagemaker:ListDomains",
                     "sagemaker:ListUserProfiles",
                     "sagemaker:ListSpaces",
                     "sagemaker:DescribeApp",
                     "sagemaker:DescribeDomain",
                     "sagemaker:DescribeUserProfile",
                     "sagemaker:DescribeSpace"
                 ],
                 "Resource": "*"
             },
             {
                 "Sid": "SMStudioAppPermissionsTagOnCreate",
                 "Effect": "Allow",
                 "Action": [
                     "sagemaker:AddTags"
                 ],
                 "Resource": "arn:aws:sagemaker:{{us-east-1}}:{{111122223333}}:*/*",
                 "Condition": {
                     "Null": {
                         "sagemaker:TaggingAction": "false"
                     }
                 }
             },
             {
                 "Sid": "SMStudioRestrictSharedSpacesWithoutOwners",
                 "Effect": "Allow",
                 "Action": [
                     "sagemaker:CreateSpace",
                     "sagemaker:UpdateSpace",
                     "sagemaker:DeleteSpace"
                 ],
                 "Resource": "arn:aws:sagemaker:{{us-east-1}}:{{111122223333}}:space/${sagemaker:DomainId}/*",
                 "Condition": {
                     "Null": {
                         "sagemaker:OwnerUserProfileArn": "true"
                     }
                 }
             },
             {
                 "Sid": "SMStudioRestrictSpacesToOwnerUserProfile",
                 "Effect": "Allow",
                 "Action": [
                     "sagemaker:CreateSpace",
                     "sagemaker:UpdateSpace",
                     "sagemaker:DeleteSpace"
                 ],
                 "Resource": "arn:aws:sagemaker:{{us-east-1}}:{{111122223333}}:space/${sagemaker:DomainId}/*",
                 "Condition": {
                     "ArnLike": {
                         "sagemaker:OwnerUserProfileArn": "arn:aws:sagemaker:us-east-1:{{111122223333}}:user-profile/${sagemaker:DomainId}/${sagemaker:UserProfileName}"
                     },
                     "StringEquals": {
                         "sagemaker:SpaceSharingType": [
                             "Private",
                             "Shared"
                         ]
                     }
                 }
             },
             {
                 "Sid": "SMStudioRestrictCreatePrivateSpaceAppsToOwnerUserProfile",
                 "Effect": "Allow",
                 "Action": [
                     "sagemaker:CreateApp",
                     "sagemaker:DeleteApp"
                 ],
                 "Resource": "arn:aws:sagemaker:{{us-east-1}}:{{111122223333}}:app/${sagemaker:DomainId}/*",
                 "Condition": {
                     "ArnLike": {
                         "sagemaker:OwnerUserProfileArn": "arn:aws:sagemaker:us-east-1:{{111122223333}}:user-profile/${sagemaker:DomainId}/${sagemaker:UserProfileName}"
                     },
                     "StringEquals": {
                         "sagemaker:SpaceSharingType": [
                             "Private"
                         ]
                     }
                 }
             },
             {
                 "Sid": "AllowAppActionsForSharedSpaces",
                 "Effect": "Allow",
                 "Action": [
                     "sagemaker:CreateApp",
                     "sagemaker:DeleteApp"
                 ],
                 "Resource": "arn:aws:sagemaker:*:*:app/${sagemaker:DomainId}/*/*/*",
                 "Condition": {
                     "StringEquals": {
                         "sagemaker:SpaceSharingType": [
                             "Shared"
                         ]
                     }
                 }
             }
         ]
     }
     ```

------
   + 由於 Studio 顯示一組擴充的應用程式，因此使用者可能有權存取之前未顯示的應用程式。管理員可以透過建立  AWS Identity and Access Management (IAM) 政策來限制對這些預設應用程式的存取，將某些應用程式的拒絕許可授予特定使用者。
**注意**  
應用程式類型可以是 `jupyterlab` 或 `codeeditor`。

------
#### [ JSON ]

****  

     ```
     {
         "Version":"2012-10-17",		 	 	 
         "Statement": [
             {
                 "Sid": "DenySageMakerCreateAppForSpecificAppTypes",
                 "Effect": "Deny",
                 "Action": "sagemaker:CreateApp",
                 "Resource": "arn:aws:sagemaker:{{us-east-1}}:{{111122223333}}:app/{{domain-id}}/*/{{app-type}}/*"
             }
         ]
     }
     ```

------

1. 將政策連接至網域的執行角色。如需指示，請遵循[新增 IAM 身分許可 (主控台)](https://docs.aws.amazon.com//IAM/latest/UserGuide/access_policies_manage-attach-detach.html#add-policies-console) 中的步驟。

## 步驟 2：更新 VPC 組態
<a name="studio-updated-migrate-vpc"></a>

如果您在 `VPC-Only` 模式中使用您的網域，請確定您的 VPC 組態符合在 `VPC-Only` 模式中使用 Studio 的要求。如需詳細資訊，請參閱[將 VPC 中的 Amazon SageMaker Studio 筆記本連線至外部資源](studio-updated-and-internet-access.md)。

## 步驟 3：升級至 Studio UI
<a name="studio-updated-migrate-set-studio-updated"></a>

將現有網域從 Studio Classic 遷移至 Studio 之前，建議您使用 Studio 搭配與現有網域相同的組態建立測試網域。

### (選用) 建立測試網域
<a name="studio-updated-migrate-ui-create-test"></a>

在遷移現有網域之前，使用此測試網域與 Studio 互動、測試聯網組態，然後啟動應用程式。

1. 取得現有網域的網域 ID。

   1. 開啟 Amazon SageMaker AI 主控台，網址為 [https://console.aws.amazon.com/sagemaker/](https://console.aws.amazon.com/sagemaker/)。

   1. 從左側導覽窗格中，展開**管理員組態**，然後選擇**網域**。

   1. 選擇現有的網域。

   1. 在**網域詳細資訊**頁面上，選擇**網域設定**標籤。

   1. 複製**網域 ID**。

1. 新增現有網域的網域 ID。

   ```
   export REF_DOMAIN_ID="{{domain-id}}"
   export SM_REGION="{{region}}"
   ```

1. 使用 `describe-domain` 取得現有網域的重要資訊。

   ```
   export REF_EXECROLE=$(aws sagemaker describe-domain --region=$SM_REGION --domain-id=$REF_DOMAIN_ID | jq -r '.DefaultUserSettings.ExecutionRole')
   export REF_VPC=$(aws sagemaker describe-domain --region=$SM_REGION --domain-id=$REF_DOMAIN_ID | jq -r '.VpcId')
   export REF_SIDS=$(aws sagemaker describe-domain --region=$SM_REGION --domain-id=$REF_DOMAIN_ID | jq -r '.SubnetIds | join(",")')
   export REF_SGS=$(aws sagemaker describe-domain --region=$SM_REGION --domain-id=$REF_DOMAIN_ID | jq -r '.DefaultUserSettings.SecurityGroups | join(",")')
   export AUTHMODE=$(aws sagemaker describe-domain --region=$SM_REGION --domain-id=$REF_DOMAIN_ID | jq -r '.AuthMode')
   ```

1. 驗證參數。

   ```
   echo "Execution Role: $REF_EXECROLE || VPCID: $REF_VPC || SubnetIDs: $REF_SIDS || Security GroupIDs: $REF_SGS || AuthMode: $AUTHMODE"
   ```

1. 使用來自現有網域的組態建立測試網域。

   ```
   IFS=',' read -r -a subnet_ids <<< "$REF_SIDS"
   IFS=',' read -r -a security_groups <<< "$REF_SGS"
   security_groups_json=$(printf '%s\n' "${security_groups[@]}" | jq -R . | jq -s .)
   
   aws sagemaker create-domain \
   --domain-name "TestV2Config" \
   --vpc-id $REF_VPC \
   --auth-mode $AUTHMODE \
   --subnet-ids "${subnet_ids[@]}" \
   --app-network-access-type VpcOnly \
   --default-user-settings "
   {
       \"ExecutionRole\": \"$REF_EXECROLE\",
       \"StudioWebPortal\": \"ENABLED\",
       \"DefaultLandingUri\": \"studio::\",
       \"SecurityGroups\": $security_groups_json
   }
   "
   ```

1. 在測試網域為 `In Service` 之後，請使用測試網域的 ID 來建立使用者設定檔。此使用者設定檔用來啟動和測試應用程式。

   ```
   aws sagemaker create-user-profile \
   --region="$SM_REGION" --domain-id={{test-domain-id}} \
   --user-profile-name test-network-user
   ```

#### 測試 Studio 功能
<a name="studio-updated-migrate-ui-testing"></a>

使用 `test-network-user` 使用者設定檔啟動測試網域。我們建議您徹底測試 Studio UI，並建立應用程式以在 `VPCOnly` 模式下測試 Studio 功能。測試下列工作流程：
+ 建立新的 JupyterLab Space、測試環境和連線。
+ 建立新的程式碼編輯器 (以 Code-OSS、Visual Studio Code - Open Source 空間為基礎)、測試環境和連線。
+ 啟動新的 Studio Classic 應用程式、測試環境和連線。
+ 使用測試讀取和寫入動作來測試 Amazon Simple Storage Service 連線。

如果這些測試成功，請升級現有的網域。如果您遇到任何失敗，建議您在更新現有網域之前修正您的環境和連線問題。

#### 清除測試網域資源
<a name="studio-updated-migrate-ui-clean"></a>

在您遷移了現有網域之後，請清除測試網域資源。

1. 新增測試網域的 ID。

   ```
   export TEST_DOMAIN="{{test-domain-id}}"
   export SM_REGION="{{region}}"
   ```

1. 列出網域中處於執行中狀態的所有應用程式。

   ```
   active_apps_json=$(aws sagemaker list-apps --region=$SM_REGION --domain-id=$TEST_DOMAIN)
   echo $active_apps_json
   ```

1. 剖析執行中應用程式的 JSON 清單並將其刪除。如果使用者嘗試建立他們沒有許可的應用程式，則以下指令碼中可能會有未擷取的空間。您必須手動刪除這些空間。

   ```
   echo "$active_apps_json" | jq -c '.Apps[]' | while read -r app;
   do
       if echo "$app" | jq -e '. | has("SpaceName")' > /dev/null;
       then
           app_type=$(echo "$app" | jq -r '.AppType')
           app_name=$(echo "$app" | jq -r '.AppName')
           domain_id=$(echo "$app" | jq -r '.DomainId')
           space_name=$(echo "$app" | jq -r '.SpaceName')
   
           echo "Deleting App - AppType: $app_type || AppName: $app_name || DomainId: $domain_id || SpaceName: $space_name"
           aws sagemaker delete-app --region=$SM_REGION --domain-id=$domain_id \
           --app-type $app_type --app-name $app_name --space-name $space_name
   
           echo "Deleting Space - AppType: $app_type || AppName: $app_name || DomainId: $domain_id || SpaceName: $space_name"
           aws sagemaker delete-space --region=$SM_REGION --domain-id=$domain_id \
           --space-name $space_name
       else
   
           app_type=$(echo "$app" | jq -r '.AppType')
           app_name=$(echo "$app" | jq -r '.AppName')
           domain_id=$(echo "$app" | jq -r '.DomainId')
           user_profile_name=$(echo "$app" | jq -r '.UserProfileName')
   
           echo "Deleting Studio Classic - AppType: $app_type || AppName: $app_name || DomainId: $domain_id || UserProfileName: $user_profile_name"
           aws sagemaker delete-app --region=$SM_REGION --domain-id=$domain_id \
           --app-type $app_type --app-name $app_name --user-profile-name $user_profile_name
   
       fi
   
   done
   ```

1. 刪除測試使用者設定檔。

   ```
   aws sagemaker delete-user-profile \
   --region=$SM_REGION --domain-id=$TEST_DOMAIN \
   --user-profile-name "test-network-user"
   ```

1. 刪除測試網域。

   ```
   aws sagemaker delete-domain \
   --region=$SM_REGION --domain-id=$TEST_DOMAIN
   ```

在使用測試網域中的組態測試了 Studio 功能之後，請遷移現有的網域。當 Studio 是網域的預設體驗時，Studio 是網域中所有使用者的預設體驗。不過，使用者設定優先於網域設定。因此，如果使用者在其使用者設定中將預設體驗設定為 Studio Classic，則該使用者將具有 Studio Classic 作為其預設體驗。

您可以從 SageMaker AI 主控台、 或 更新現有網域 AWS CLI，以遷移現有網域 AWS CloudFormation。選擇下列其中一個索引標籤，以檢視相關指示。

### 使用 SageMaker AI 主控台將 Studio 設定為現有網域的預設體驗
<a name="studio-updated-migrate-set-studio-updated-console"></a>

您可以使用 SageMaker AI 主控台，將 Studio 設定為現有網域的預設體驗。

1. 開啟 Amazon SageMaker AI 主控台，網址為 [https://console.aws.amazon.com/sagemaker/](https://console.aws.amazon.com/sagemaker/)。

1. 從左側導覽窗格中展開**管理員組態**，然後選擇**網域**。

1. 選擇您要啟用 Studio 作為其預設體驗的現有網域。

1. 在**網域詳細資訊**頁面上展開**啟用新的 Studio**。

1. (選用) 若要檢視啟用 Studio 作為預設體驗所涉及步驟的詳細資訊，請選擇**檢視詳細資訊**。此頁面會顯示下列項目：
   + 在 **SageMaker Studio 概觀**區段中，您可以檢視 Studio Web 型介面中包含或可用的應用程式。
   + 在**啟用程序**區段中，您可以檢視要啟用 Studio 之工作流程任務的描述。
**注意**  
您將需要手動遷移資料。如需遷移資料的指示，請參閱 [(選用) 將資料從 Studio Classic 遷移至 Studio](studio-updated-migrate-data.md)。
   + 在**還原至 Studio Classic 體驗**區段中，您可以檢視如何在啟用 Studio 作為預設體驗之後還原回 Studio Classic。

1. 若要開始啟用 Studio 作為預設體驗的程序，請選擇**啟用新的 Studio**。

1. 在**指定和設定角色**區段中，您可以檢視自動包含在 Studio 中的預設應用程式。

   若要防止使用者執行這些應用程式，請選擇其 IAM 政策拒絕存取的 AWS Identity and Access Management (IAM) 角色。如需如何建立政策以限制存取的相關資訊，請參閱 [步驟 1：更新應用程式建立許可](#studio-updated-migrate-limit-apps)。

1. 在**選擇預設 S3 儲存貯體以連接 CORS 政策**區段中，您可以授權 Studio 存取 Amazon S3 儲存貯體。在此情況下，預設 Amazon S3 儲存貯體是 Studio Classic 的預設 Amazon S3 儲存貯體。在此步驟中，您可以執行以下動作：
   + 驗證 CORS 政策要連接至其中的網域預設 Amazon S3 儲存貯體。如果您的網域沒有預設 Amazon S3 儲存貯體，SageMaker AI 會建立一個連接正確 CORS 政策的 Amazon S3 儲存貯體。
   + 您可以包含 10 個額外的 Amazon S3 儲存貯體，以連接 CORS 政策。

     如果您想要包含超過 10 個儲存貯體，您可以手動新增它們。如需手動將 CORS 政策連接至 Amazon S3 儲存貯體的詳細資訊，請參閱 [(選用) 更新您的 CORS 政策以存取 Amazon S3 儲存貯體](#studio-updated-migrate-cors)。

   若要繼續，請選取**您是否同意覆寫所選 Amazon S3 儲存貯體上的任何現有 CORS 政策？**旁邊的核取方塊。

1. **遷移資料**區段包含 Studio Classic 和 Studio 不同資料儲存磁碟區的相關資訊。您的資料不會透過此程序自動遷移。如需遷移資料、生命週期組態和 JupyterLab 延伸模組的指示，請參閱 [(選用) 將資料從 Studio Classic 遷移至 Studio](studio-updated-migrate-data.md)。

1. 一旦完成了頁面上的任務並驗證了組態，請選擇**啟用新的 Studio**。

### 使用 將 Studio 設定為現有網域的預設體驗 AWS CLI
<a name="studio-updated-migrate-set-studio-updated-cli"></a>

若要使用 AWS CLI將 Studio 設定為現有網域的預設體驗，請使用 [update-domain](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/sagemaker/update-domain.html) 呼叫。您必須將 `ENABLED` 設定為 `StudioWebPortal` 的值，並將 `studio::` 設定為 `DefaultLandingUri` 的值，作為 `default-user-settings` 參數的一部分。 

`StudioWebPortal` 指出 Studio 體驗是否為預設體驗，而 `DefaultLandingUri` 指出使用者存取網域時導向至其中的預設體驗。在此範例中，在網域層級設定這些值 (在 `default-user-settings` 中)，可讓 Studio 成為網域內使用者的預設體驗。

如果網域內的使用者將其 `StudioWebPortal` 設定為 `DISABLED`，並在使用者層級將 `DefaultLandingUri` 設定為 `app:JupyterServer:` (在 `UserSettings` 中)，則這優先於網域設定。換言之，無論網域設定為何，該使用者都會有 Studio Classic 作為其預設體驗。

下列程式碼範例展示如何將 Studio 設定為網域內使用者的預設體驗：

```
aws sagemaker update-domain \
--domain-id {{existing-domain-id}} \
--region {{AWS 區域}} \
--default-user-settings '
{
    "StudioWebPortal": "ENABLED",
    "DefaultLandingUri": "studio::"
}
'
```
+ 若要取得您的 `{{existing-domain-id}}`，請使用下列指示：

**取得 `{{existing-domain-id}}`**

  1. 開啟 Amazon SageMaker AI 主控台，網址為 [https://console.aws.amazon.com/sagemaker/](https://console.aws.amazon.com/sagemaker/)。

  1. 從左側導覽窗格中，展開**管理員組態**，然後選擇**網域**。

  1. 選擇現有的網域。

  1. 在**網域詳細資訊**頁面上，選擇**網域設定**標籤。

  1. 複製**網域 ID**。
+ 為確保您的 AWS 區域 網域使用正確的 ，請使用下列指示：

**取得 `{{AWS 區域}}`**

  1. 開啟 Amazon SageMaker AI 主控台，網址為 [https://console.aws.amazon.com/sagemaker/](https://console.aws.amazon.com/sagemaker/)。

  1. 從左側導覽窗格中，展開**管理員組態**，然後選擇**網域**。

  1. 選擇現有的網域。

  1. 在**網域詳細資訊**頁面上，驗證這是否為現有的網域。

  1. 從 SageMaker AI 主控台右上角展開 AWS 區域 下拉式清單，並使用您 AWS 區域 名稱右側的對應 AWS 區域 ID。例如 `us-west-1`。

將預設體驗遷移至 Studio 之後，您可以讓 Studio 存取 Amazon S3 儲存貯體。例如，您可以包含對 Studio Classic 預設 Amazon S3 儲存貯體和其他 Amazon S3 儲存貯體的存取。若要這麼做，您必須手動將[跨來源資源共用](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) (CORS) 組態附加至 Amazon S3 儲存貯體。如需如何手動將 CORS 政策連接至 Amazon S3 儲存貯體的詳細資訊，請參閱 [(選用) 更新您的 CORS 政策以存取 Amazon S3 儲存貯體](#studio-updated-migrate-cors)。

同樣地，當您 AWS CLI 使用 create [-domain](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/sagemaker/create-domain.html) 呼叫從 建立網域時，您可以將 Studio 設定為預設體驗。 

### 使用 將 Studio 設定為現有網域的預設體驗 AWS CloudFormation
<a name="studio-updated-migrate-set-studio-updated-cloud-formation"></a>

您可以使用 AWS CloudFormation來設定建立網域時的預設體驗。如需 CloudFormation 遷移範本，請參閱 [SageMaker Studio 管理員 IaC 範本](https://github.com/aws-samples/sagemaker-studio-admin-iac-templates/tree/main?tab=readme-ov-file#phase-1-migration)。如需使用 建立網域的詳細資訊 CloudFormation，請參閱[使用 建立 Amazon SageMaker AI 網域 CloudFormation](https://github.com/aws-samples/cloudformation-studio-domain?tab=readme-ov-file#creating-sagemaker-studio-domains-using-cloudformation)。

如需 所支援網域資源的相關資訊 AWS CloudFormation，請參閱 [AWS：：SageMaker AI：：Domain](https://docs.aws.amazon.com//AWSCloudFormation/latest/UserGuide/aws-resource-sagemaker-domain.html#cfn-sagemaker-domain-defaultusersettings)。

將預設體驗遷移至 Studio 之後，您可以讓 Studio 存取 Amazon S3 儲存貯體。例如，您可以包含對 Studio Classic 預設 Amazon S3 儲存貯體和其他 Amazon S3 儲存貯體的存取。若要這麼做，您必須手動將[跨來源資源共用](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) (CORS) 組態附加至 Amazon S3 儲存貯體。如需如何手動將 CORS 政策連接至 Amazon S3 儲存貯體的相關資訊，請參閱 [(選用) 更新您的 CORS 政策以存取 Amazon S3 儲存貯體](#studio-updated-migrate-cors)。

### (選用) 更新您的 CORS 政策以存取 Amazon S3 儲存貯體
<a name="studio-updated-migrate-cors"></a>

在 Studio Classic 中，使用者可以建立檔案、列出檔案，以及將檔案上傳至 Amazon Simple Storage Service (Amazon S3) 儲存貯體。若要支援 Studio 中的相同體驗，管理員必須將[跨來源資源共用](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) (CORS) 組態連接至 Amazon S3 儲存貯體。這是必要的，因為 Studio 會從網際網路瀏覽器進行 Amazon S3 呼叫。瀏覽器會代表使用者調用 CORS。因此，除非 CORS 政策連接至 Amazon S3 儲存貯體，否則所有對 Amazon S3 儲存貯體的請求都會失敗。

您可能需要手動將 CORS 政策連接至 Amazon S3 儲存貯體，原因如下。
+ 如果在將現有網域的預設體驗遷移到 Studio 時，已有一個未連接正確 CORS 策略的現有 Amazon S3 預設儲存貯體。
+ 如果您使用 AWS CLI 將現有網域的預設體驗遷移至 Studio。如需使用 AWS CLI 進行遷移的詳細資訊，請參閱 [使用 將 Studio 設定為現有網域的預設體驗 AWS CLI](#studio-updated-migrate-set-studio-updated-cli)。
+ 如果您想要將 CORS 政策連接至其他 Amazon S3 儲存貯體。

**注意**  
如果您打算使用 SageMaker AI 主控台來啟用 Studio 作為預設體驗，您將 CORS 政策連接至其中的 Amazon S3 儲存貯體將在遷移期間覆寫其現有的 CORS 政策。因此，您可以忽略下列手動指示。  
不過，如果您已經使用 SageMaker AI 主控台進行遷移，並想要包含更多 Amazon S3 儲存貯體來連接 CORS 政策，則請繼續執行下列手動指示。

下列程序說明如何手動將 CORS 組態新增至 Amazon S3 儲存貯體。

**將 CORS 組態新增至 Amazon S3 儲存貯體**

1. 確認 Amazon S3 儲存貯體與具有下列名稱 AWS 區域 的現有網域位於相同的 中。如需指示，請參閱[檢視 Amazon S3 儲存貯體的屬性](https://docs.aws.amazon.com//AmazonS3/latest/userguide/view-bucket-properties.html)。

   ```
   sagemaker-{{region}}-{{account-id}}
   ```

1. 將具有下列內容的 CORS 組態新增至預設 Amazon S3 儲存貯體。如需指示，請參閱[設定跨來源資源共用 (CORS)](https://docs.aws.amazon.com//AmazonS3/latest/userguide/enabling-cors-examples.html)。

   ```
   [
       {
           "AllowedHeaders": [
               "*"
           ],
           "AllowedMethods": [
               "POST",
               "PUT",
               "GET",
               "HEAD",
               "DELETE"
           ],
           "AllowedOrigins": [
               "https://*.sagemaker.aws"
           ],
           "ExposeHeaders": [
               "ETag",
               "x-amz-delete-marker",
               "x-amz-id-2",
               "x-amz-request-id",
               "x-amz-server-side-encryption",
               "x-amz-version-id"
           ]
       }
   ]
   ```

### (選用) 從 Studio Classic 中的 Data Wrangler 遷移至 SageMaker Canvas
<a name="studio-updated-migrate-dw"></a>

Amazon SageMaker Data Wrangler 作為 Studio Classic 體驗中的自有功能而存在。當您啟用 Studio 作為預設體驗時，請使用 [Amazon SageMaker Canvas](https://docs.aws.amazon.com/sagemaker/latest/dg/canvas.html) 應用程式來存取 Data Wrangler 功能。SageMaker Canvas 是一種應用程式，您可以在其中訓練和部署機器學習模型，而無需撰寫任何程式碼，並且 Canvas 會提供 Data Wrangler 支援的資料準備功能。

新的 Studio 體驗不支援傳統 Data Wrangler UI，如果您想要繼續使用 Data Wrangler，則必須建立 Canvas 應用程式。不過，您必須擁有必要的許可，才能建立和使用 Canvas 應用程式。

請完成下列步驟，將必要的許可政策連接至 SageMaker AI 網域或使用者的 IAM AWS 角色。

**授與 Canvas 內 Data Wrangler 功能的許可**

1. 將 AWS 受管政策 [AmazonSageMakerFullAccess](https://docs.aws.amazon.com/sagemaker/latest/dg/security-iam-awsmanpol.html#security-iam-awsmanpol-AmazonSageMakerFullAccess) 連接至使用者的 IAM 角色。如需說明如何將 IAM 政策附加至角色的程序，請參閱《AWS IAM 使用者指南》**中的[新增 IAM 身分許可 (主控台)](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_manage-attach-detach.html#add-policies-console)。

   如果此許可政策對您的使用案例而言過於寬鬆，您可以建立至少包含下列許可的縮小範圍政策：

   ```
   {
       "Sid": "AllowStudioActions",
       "Effect": "Allow",
       "Action": [
           "sagemaker:CreatePresignedDomainUrl",
           "sagemaker:DescribeDomain",
           "sagemaker:ListDomains",
           "sagemaker:DescribeUserProfile",
           "sagemaker:ListUserProfiles",
           "sagemaker:DescribeSpace",
           "sagemaker:ListSpaces",
           "sagemaker:DescribeApp",
           "sagemaker:ListApps"
       ],
       "Resource": "*"
   },
   {
       "Sid": "AllowAppActionsForUserProfile",
       "Effect": "Allow",
       "Action": [
           "sagemaker:CreateApp",
           "sagemaker:DeleteApp"
       ],
       "Resource": "arn:aws:sagemaker:{{region}}:{{account-id}}:app/{{domain-id}}/{{user-profile-name}}/canvas/*",
       "Condition": {
           "Null": {
               "sagemaker:OwnerUserProfileArn": "true"
           }
       }
   }
   ```

1. 將 AWS 受管政策 [AmazonSageMakerCanvasDataPrepFullAccess](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonSageMakerCanvasDataPrepFullAccess.html) 連接至使用者的 IAM 角色。

在連接必要的許可之後，您可以建立 Canvas 應用程式並登入。如需詳細資訊，請參閱[Amazon Sagemaker Canvas 使用入門](canvas-getting-started.md)。

登入 Canvas 後，您可以直接存取 Data Wrangler 並開始建立資料流程。如需詳細資訊，請參閱 Canvas 文件中的 [資料準備](canvas-data-prep.md)。

### (選用) 從 Studio Classic 中的 Autopilot 遷移至 SageMaker Canvas
<a name="studio-updated-migrate-autopilot"></a>

[Amazon SageMaker Autopilot](https://docs.aws.amazon.com/sagemaker/AWSIronmanApiDoc/integ/npepin-studio-migration-autopilot-to-canvas/latest/dg/autopilot-automate-model-development.html) 作為 Studio Classic 體驗中的自有功能而存在。當您遷移至使用更新的 Studio 體驗時，請使用 [Amazon SageMaker Canvas](https://docs.aws.amazon.com/sagemaker/latest/dg/canvas.html) 應用程式，透過使用者介面 (UI) 繼續使用相同的自動化機器學習 (AutoML) 功能。SageMaker Canvas 是一種應用程式，您可以在其中訓練和部署機器學習模型，而無需撰寫任何程式碼，而 Canvas 會提供 UI 來執行 AutoML 任務。

新的 Studio 體驗不支援傳統 Autopilot UI。如果您想要透過 UI 繼續使用 Autopilot 的 AutoML 功能，則必須建立 Canvas 應用程式。

不過，您必須擁有必要的許可，才能建立和使用 Canvas 應用程式。
+ 如果您是從 Studio 存取 SageMaker Canvas，請將這些許可新增至 SageMaker AI 網域或使用者設定檔的執行角色。
+ 如果您是從主控台存取 SageMaker Canvas，請將這些許可新增至使用者的 IAM AWS 角色。
+ 如果您透過[預先簽章的 URL](https://docs.aws.amazon.com/sagemaker/latest/dg/setting-up-canvas-sso.html#canvas-optional-access) 存取 SageMaker Canvas，請將這些許可新增至您用於 Okta SSO 存取的 IAM 角色。

若要在 Canvas 中啟用 AutoML 功能，請將下列政策新增至您的執行角色或 IAM 使用者角色。
+ AWS 受管政策：[`CanvasFullAccess`。](https://docs.aws.amazon.com/sagemaker/latest/dg/security-iam-awsmanpol-canvas.html#security-iam-awsmanpol-AmazonSageMakerCanvasFullAccess)
+ 內嵌政策：

  ```
  {
      "Sid": "AllowAppActionsForUserProfile",
      "Effect": "Allow",
      "Action": [
          "sagemaker:CreateApp",
          "sagemaker:DeleteApp"
      ],
      "Resource": "arn:aws:sagemaker:{{region}}:{{account-id}}:app/{{domain-id}}/{{user-profile-name}}/canvas/*",
      "Condition": {
          "Null": {
              "sagemaker:OwnerUserProfileArn": "true"
          }
      }
  }
  ```

**將 IAM 政策連接至執行角色**

1. 

**尋找連接至 SageMaker AI 使用者設定檔的執行角色**

   1. 在 SageMaker AI 主控台 [https://console.aws.amazon.com/sagemaker/](https://console.aws.amazon.com/sagemaker/) 中，導覽至**網域**，然後選擇您的 SageMaker AI 網域。

   1. 執行角色 ARN 會列示在使用者設定檔的**使用者詳細資訊**頁面上的*執行角色*下。請記下 ARN 中的執行角色名稱。

   1. 在 IAM 主控台 [https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/) 中，選擇**角色**。

   1. 在搜尋欄位中依名稱搜尋您的角色。

   1. 設定角色。

1. 將政策新增至該角色

   1. 在 IAM 主控台 [https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/) 中，選擇**角色**。

   1. 在搜尋欄位中依名稱搜尋您的角色。

   1. 設定角色。

   1. 在**許可**索引標籤中，導覽至下拉式功能表**新增許可**。

   1. 
      + 針對受管政策：選取**連接政策**，搜尋您要連接的管理政策名稱。

        選取政策，然後選擇**新增許可**。
      + 對於內嵌政策：選取**建立內嵌政策**、在 JSON 索引標籤中貼上您的政策、選擇下一步、為您的政策命名，然後選擇**建立**。

如需說明如何將 IAM 政策附加至角色的程序，請參閱《AWS IAM 使用者指南》**中的[新增 IAM 身分許可 (主控台)](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_manage-attach-detach.html#add-policies-console)。

在連接必要的許可之後，您可以建立 Canvas 應用程式並登入。如需詳細資訊，請參閱[Amazon Sagemaker Canvas 使用入門](canvas-getting-started.md)。

## 將 Studio Classic 設定為預設體驗
<a name="studio-updated-migrate-revert"></a>

管理員可以將 Studio Classic 還原為現有網域的預設體驗。可以透過 AWS CLI來完成此動作。

**注意**  
當 Studio Classic 設定為網域層級的預設體驗時，Studio Classic 是網域中所有使用者的預設體驗。不過，使用者層級的設定優先於網域層級設定。因此，如果使用者將其預設體驗設定為 Studio，則該使用者將具有 Studio 作為預設體驗。

若要使用 還原為 Studio Classic 作為現有網域的預設體驗 AWS CLI，請使用 [update-domain](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/sagemaker/update-domain.html) 呼叫。作為 `default-user-settings` 欄位的一部分，您必須設定：
+ `StudioWebPortal` 值為 `DISABLED`。
+ `DefaultLandingUri` 值為 `app:JupyterServer:`

`StudioWebPortal` 指出 Studio 體驗是否為預設體驗，而 `DefaultLandingUri` 指出使用者存取網域時導向至其中的預設體驗。在此範例中，在網域層級設定這些值 (在 `default-user-settings` 中)，可讓 Studio Classic 成為網域內使用者的預設體驗。

如果網域內的使用者將其 `StudioWebPortal` 設定為 `ENABLED`，並在使用者層級將 `DefaultLandingUri` 設定為 `studio::` (在 `UserSettings` 中)，則這優先於網域層級設定。換言之，無論網域層級設定為何，該使用者都會有 Studio 作為其預設體驗。

下列程式碼範例展示如何將 Studio Classic 設定為網域內使用者的預設體驗：

```
aws sagemaker update-domain \
--domain-id {{existing-domain-id}} \
--region {{AWS 區域}} \
--default-user-settings '
{
    "StudioWebPortal": "DISABLED",
    "DefaultLandingUri": "app:JupyterServer:"
}
'
```

使用下列指示來取得您的 `{{existing-domain-id}}`。

1. 開啟 Amazon SageMaker AI 主控台，網址為 [https://console.aws.amazon.com/sagemaker/](https://console.aws.amazon.com/sagemaker/)。

1. 從左側導覽窗格中，展開**管理員組態**，然後選擇**網域**。

1. 選擇現有的網域。

1. 在**網域詳細資訊**頁面上，選擇**網域設定**標籤。

1. 複製**網域 ID**。

若要取得您的 `{{AWS 區域}}`，請使用下列指示，以確保您 AWS 區域 的網域使用正確的 。

1. 開啟位在 [https://console.aws.amazon.com/sagemaker/](https://console.aws.amazon.com/sagemaker/) 的 Amazon SageMaker AI 主控台。

1. 從左側導覽窗格中，展開**管理員組態**，然後選擇**網域**。

1. 選擇現有的網域。

1. 在**網域詳細資訊**頁面上，驗證這是否為現有的網域。

1. 從 SageMaker AI 主控台右上角展開 AWS 區域 下拉式清單，並使用您 AWS 區域 名稱右側的對應 AWS 區域 ID。例如 `us-west-1`。