正在加载…
未找到任何结果。

    Quick tip: Review the prerequisites before you run the lab
    Use an Incognito or private browser window to run this lab. This prevents any conflicts between your personal account and the student account, which may cause extra charges incurred to your personal account.
    欢迎加入我们的社区,一起测试和分享您的知识!
    done
    学习 700 多个动手实验和课程并获得相关技能徽章

    Set Up an App Dev Environment on Google Cloud:挑戰研究室

    实验 1 小时 universal_currency_alt 1 积分 show_chart 入门级
    info 此实验可能会提供 AI 工具来支持您学习。
    欢迎加入我们的社区,一起测试和分享您的知识!
    done
    学习 700 多个动手实验和课程并获得相关技能徽章

    GSP315

    Google Cloud 自學實驗室標誌

    簡介

    在挑戰研究室中,您會在特定情境下完成一系列任務。挑戰研究室不會提供逐步說明,您將運用從課程研究室學到的技巧,自行找出方法完成任務!自動評分系統 (如本頁所示) 將根據您是否正確完成任務來提供意見回饋。

    在您完成任務的期間,挑戰研究室不會介紹新的 Google Cloud 概念。您須靈活運用所學技巧,例如變更預設值或詳讀並研究錯誤訊息,解決遇到的問題。

    若想滿分達標,就必須在時限內成功完成所有任務!

    這個研究室適合已參加 Set Up an App Dev Environment on Google Cloud 技能徽章課程的學員。準備好迎接挑戰了嗎?

    設定

    點選「Start Lab」按鈕前的須知事項

    請詳閱以下操作說明。研究室活動會計時,而且中途無法暫停。點選「Start Lab」 後就會開始計時,讓您瞭解有多少時間可以使用 Google Cloud 資源。

    您將在真正的雲端環境中完成實作研究室活動,而不是在模擬或示範環境。為達此目的,我們會提供新的暫時憑證,讓您用來在研究室活動期間登入及存取 Google Cloud。

    如要完成這個研究室活動,請先確認:

    • 您可以使用標準的網際網路瀏覽器 (Chrome 瀏覽器為佳)。
    注意:請使用無痕模式或私密瀏覽視窗執行此研究室。這可以防止個人帳戶和學生帳戶之間的衝突,避免個人帳戶產生額外費用。
    • 是時候完成研究室活動了!別忘了,活動一開始將無法暫停。
    注意:如果您擁有個人 Google Cloud 帳戶或專案,請勿用於本研究室,以免產生額外費用。

    挑戰情境

    您剛以「初階雲端工程師」的職銜進入 Jooli 公司,目前已協助多個團隊建立及管理 Google Cloud 資源。

    公司預期您具備執行這些工作所需的技能與知識,因此不會提供逐步指南。

    您的挑戰

    現在,您必須協助新成立的開發團隊完成新專案「回憶」的幾項初期工作,這項專案用於儲存及整理相片。您要協助「回憶」團隊進行應用程式開發環境的初始設定。

    您收到完成下列工作的要求:

    • 建立用來儲存相片的值區。
    • 建立 Pub/Sub 主題,會用於您建立的 Cloud 函式。
    • 建立 Cloud 函式。
    • 將前任雲端工程師的存取權從「回憶」專案中移除。

    您必須遵守下列幾項 Jooli 公司標準:

    • 如未特別指定,所有資源均須建立於 區域和 可用區。
    • 請使用專案虛擬私有雲。
    • 名稱通常為「team-resource」,例如執行個體的名稱可以是「kraken-webserver1」。
    • 分配符合成本效益的資源大小。專案會受到監控。如果超量使用資源,該項資源所屬的專案就會終止,您的專案也有可能受到影響,因此請特別留意。監控團隊的指引如下:如未特別指定,小型 Linux VM 請使用 e2-micro,Windows 或 Kubernetes 節點等其他用途請使用 e2-medium

    以下詳細說明各項工作,祝您好運!

    工作 1:建立值區

    您必須建立名為 的值區,以便儲存相片。 資源務必建立於 區域的 可用區。

    點選「Check my progress」,確認目標已達成。 建立名為 的值區

    工作 2:建立 Pub/Sub 主題

    建立名為 的 Pub/Sub 主題,讓 Cloud 函式傳送訊息。

    點選「Check my progress」,確認目標已達成。 建立名為 的 Pub/Sub 主題

    工作 3:建立縮圖 Cloud 函式

    建立 Cloud 函式 ,運用新增至 值區的圖片建立縮圖。 該 Cloud 函式務必使用第 2 代環境。 資源務必建立於 區域的 可用區。

    1. 建立名為 的 Cloud 函式
    注意事項: 每當您在工作 1 建立的值區中建立物件時,都要執行這個 Cloud 函式。 過程中,這個 Cloud 函式可能會要求啟用 API。 請按照要求,啟用各個必要 API。
    1. 請務必將「進入點」 (要執行的函式) 設為 ,並將「觸發條件」 設為 Cloud Storage

    2. 將下列程式碼加入 index.js

    const functions = require('@google-cloud/functions-framework'); const crc32 = require("fast-crc32c"); const { Storage } = require('@google-cloud/storage'); const gcs = new Storage(); const { PubSub } = require('@google-cloud/pubsub'); const imagemagick = require("imagemagick-stream"); functions.cloudEvent('{{{ project_0.startup_script.function }}}', cloudEvent => { const event = cloudEvent.data; console.log(`Event: ${event}`); console.log(`Hello ${event.bucket}`); const fileName = event.name; const bucketName = event.bucket; const size = "64x64" const bucket = gcs.bucket(bucketName); const topicName = "{{{ project_0.startup_script.topic }}}"; const pubsub = new PubSub(); if ( fileName.search("64x64_thumbnail") == -1 ){ // doesn't have a thumbnail, get the filename extension var filename_split = fileName.split('.'); var filename_ext = filename_split[filename_split.length - 1]; var filename_without_ext = fileName.substring(0, fileName.length - filename_ext.length ); if (filename_ext.toLowerCase() == 'png' || filename_ext.toLowerCase() == 'jpg'){ // only support png and jpg at this point console.log(`Processing Original: gs://${bucketName}/${fileName}`); const gcsObject = bucket.file(fileName); let newFilename = filename_without_ext + size + '_thumbnail.' + filename_ext; let gcsNewObject = bucket.file(newFilename); let srcStream = gcsObject.createReadStream(); let dstStream = gcsNewObject.createWriteStream(); let resize = imagemagick().resize(size).quality(90); srcStream.pipe(resize).pipe(dstStream); return new Promise((resolve, reject) => { dstStream .on("error", (err) => { console.log(`Error: ${err}`); reject(err); }) .on("finish", () => { console.log(`Success: ${fileName} → ${newFilename}`); // set the content-type gcsNewObject.setMetadata( { contentType: 'image/'+ filename_ext.toLowerCase() }, function(err, apiResponse) {}); pubsub .topic(topicName) .publisher() .publish(Buffer.from(newFilename)) .then(messageId => { console.log(`Message ${messageId} published.`); }) .catch(err => { console.error('ERROR:', err); }); }); }); } else { console.log(`gs://${bucketName}/${fileName} is not an image I can handle`); } } else { console.log(`gs://${bucketName}/${fileName} already has a thumbnail`); } });
    1. 將下列程式碼加入 package.json
    { "name": "thumbnails", "version": "1.0.0", "description": "Create Thumbnail of uploaded image", "scripts": { "start": "node index.js" }, "dependencies": { "@google-cloud/functions-framework": "^3.0.0", "@google-cloud/pubsub": "^2.0.0", "@google-cloud/storage": "^5.0.0", "fast-crc32c": "1.0.4", "imagemagick-stream": "4.1.1" }, "devDependencies": {}, "engines": { "node": ">=4.3.2" } }

    確認是否已成功建立縮圖。

    點選「Check my progress」,確認目標已達成。 驗證 Cloud 函式

    工作 4:測試基礎架構

    您必須將一張 JPG 或 PNG 圖片上傳至值區

    1. 將一張 PNG 或 JPG 圖片上傳至 值區。
    注意事項:您也可以將這張圖片 (https://storage.googleapis.com/cloud-training/gsp315/map.jpg) 下載至自有機器,然後上傳至值區。
    1. 請稍後片刻,接著點選「值區詳細資料」頁面中的「重新整理」按鈕,,您應該就會看見縮圖圖片。

    工作 5:移除前任雲端工程師

    您會看見這項專案定義了兩位使用者。

    • 其一是您的帳戶 (,角色為「擁有者」),
    • 另一位則是前任雲端工程師 (,角色為「檢視者」)。
    1. 將前任雲端工程師的存取權從專案中移除。

    點選「Check my progress」,確認目標已達成。 移除前任雲端工程師

    恭喜!

    Set Up an App Dev Environment on Google Cloud

    取得下一枚技能徽章

    這個自修研究室屬於 Set Up an App Dev Environment on Google Cloud 技能徽章課程的一部分。完成這個技能徽章課程即可獲得上方的徽章,表彰您的成就。您可以在履歷表和社群平台分享徽章,並使用 #GoogleCloudBadge 公開成就。

    這個技能徽章課程是 Google「在 Google Cloud 中執行基本的基礎架構工作」和「雲端架構師」學習路徑的一部分。如果您已完成這個學習路徑中的其他技能徽章課程,歡迎瀏覽 Google Cloud Skills Boost 目錄,找出其他可以參加的技能徽章課程。

    Google Cloud 教育訓練與認證

    協助您瞭解如何充分運用 Google Cloud 的技術。我們的課程會介紹專業技能和最佳做法,讓您可以快速掌握要領並持續進修。我們提供從基本到進階等級的訓練課程,並有隨選、線上和虛擬課程等選項,方便您抽空參加。認證可協助您驗證及證明自己在 Google Cloud 技術方面的技能和專業知識。

    使用手冊上次更新日期:2024 年 3 月 21 日

    研究室上次測試日期:2023 年 9 月 19 日

    Copyright 2025 Google LLC 保留所有權利。Google 和 Google 標誌是 Google LLC 的商標,其他公司和產品名稱則有可能是其關聯公司的商標。

    Before you begin

    1. Labs create a Google Cloud project and resources for a fixed time
    2. Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
    3. On the top left of your screen, click Start lab to begin

    Use private browsing

    1. Copy the provided Username and Password for the lab
    2. Click Open console in private mode

    Sign in to the Console

    1. Sign in using your lab credentials. Using other credentials might cause errors or incur charges.
    2. Accept the terms, and skip the recovery resource page
    3. Don't click End lab unless you've finished the lab or want to restart it, as it will clear your work and remove the project

    此内容目前不可用

    一旦可用,我们会通过电子邮件告知您

    太好了!

    一旦可用,我们会通过电子邮件告知您

    One lab at a time

    Confirm to end all existing labs and start this one

    Setup your console before you begin

    Use an Incognito or private browser window to run this lab. This prevents any conflicts between your personal account and the Student account, which may cause extra charges incurred to your personal account.