<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Daniel Villegas on Medium]]></title>
        <description><![CDATA[Stories by Daniel Villegas on Medium]]></description>
        <link>https://medium.com/@daniel.villegas?source=rss-c83442440f33------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*XNRWVVvUsg3gb8UuHTu-7w.jpeg</url>
            <title>Stories by Daniel Villegas on Medium</title>
            <link>https://medium.com/@daniel.villegas?source=rss-c83442440f33------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 13:56:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@daniel.villegas/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Gemini Enterprise Series: Enable MS SharePoint & Outlook Connectors in less than 10 minutes]]></title>
            <link>https://medium.com/google-cloud/gemini-enterprise-series-enable-ms-sharepoint-outlook-connectors-in-less-than-10-minutes-18800d1409ed?source=rss-c83442440f33------2</link>
            <guid isPermaLink="false">https://medium.com/p/18800d1409ed</guid>
            <category><![CDATA[google-gemini-ai]]></category>
            <category><![CDATA[gemini]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[gemini-enterprise]]></category>
            <category><![CDATA[google-cloud]]></category>
            <dc:creator><![CDATA[Daniel Villegas]]></dc:creator>
            <pubDate>Fri, 06 Nov 2026 04:23:08 GMT</pubDate>
            <atom:updated>2026-11-06T17:51:11.232Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fMypfhj-96M8bzcOarHyaQ.jpeg" /></figure><p>As AI adoption accelerates across enterprises, connecting Google Cloud Gemini Enterprise to Microsoft 365 is essential for unified workforce search and productivity. This step-by-step tutorial walks through registering Gemini Enterprise as an OAuth 2.0 application in Microsoft Entra ID, granting delegated Microsoft Graph and SharePoint API permissions, and setting up Federated Search and Actions connectors (Data Stores) for Microsoft SharePoint Online and Microsoft Outlook.</p><h3>Overview</h3><p>The <a href="https://docs.cloud.google.com/gemini/enterprise/docs">Gemini Enterprise App</a> is Google Cloud’s solution for enterprise-wide deployment of AI for the workforce. It provides an AI-powered enterprise search and assistant platform built on Google Cloud. It enables organizations to connect hundreds of data repositories — including Microsoft 365 services like <strong>Microsoft SharePoint</strong> and <strong>Microsoft Outlook</strong> — allowing users to securely query, discover, synthesize, and act upon corporate data using Google’s advanced generative AI models. This guide provides a comprehensive overview of how you can bring the best of Google’s AI capabilities to your corporate Microsoft 365 environment.</p><h4>What we will cover in this guide</h4><ol><li>Setting up Gemini Enterprise as a third-party OAuth 2.0 application in <strong>Microsoft Entra ID</strong>.</li><li>Creating the <strong>Client ID</strong> and <strong>Client Secret</strong>, retrieving the <strong>Tenant ID</strong>, and configuring the required delegated <strong>API permissions</strong> (with Admin Consent) so that the Gemini Enterprise App can authenticate on behalf of the user to your Microsoft 365 environment.</li><li>Setting up the <strong>Microsoft Outlook</strong> and <strong>Microsoft SharePoint</strong> Connectors (Data Stores) step by step in the <strong>Gemini Enterprise Admin Console</strong>.</li></ol><h4>GCP and Microsoft Services used for the solution:</h4><ul><li><strong>GCP Gemini Enterprise App</strong> (Data Stores &amp; Federated Search/Actions Connectors)</li><li><strong>Microsoft Entra ID</strong> (App Registrations, OAuth 2.0 Credentials &amp; API Permissions)</li><li><strong>Microsoft 365 Admin Center</strong> (Organization Information &amp; Tenant ID)</li><li><strong>Microsoft Outlook</strong></li><li><strong>Microsoft SharePoint Online</strong></li></ul><h4>Understanding User Federation for Gemini Enterprise &amp; Microsoft 365</h4><p>Before diving into the console screens, it is important to understand how identity and data access work together when connecting <strong>Google Cloud Gemini Enterprise</strong> to <strong>Microsoft 365 </strong>, and why Google Cloud now recommends <strong>Federated Search</strong> over traditional <strong>Data Ingestion</strong> connectors for these workloads.</p><h4>How the New Recommended User Federation Works (Google Identity + Entra ID OAuth 2.0)</h4><p>In a modern enterprise environment running both Google Cloud and Microsoft 365, the recommended architecture separates <strong>application sign-in</strong> from <strong>data-source authorization</strong> using a clean, two-layer federation model:</p><ul><li><strong>Layer 1 — Application Sign-In via Google Identity:</strong> End users sign into the Gemini Enterprise web or mobile interface using their <strong>Google Identity</strong> (Cloud Identity or Google Workspace account). In most dual-cloud enterprises, Cloud Identity is already federated with <strong>Microsoft Entra ID</strong> for single sign-on (SSO) and provisioned with matching corporate email addresses (User Principal Names, or UPNs). Because Gemini Enterprise uses Google Identity for application-level access, you do <strong>not</strong> need to configure complex Workforce Identity Federation (WIF) pools or replicate Microsoft Entra ID security groups into Google Cloud just to query M365 data. You may still use WIF if you prefer, although it comes with its own tradeoffs and its out of scope for this particular guide.</li><li><strong>Layer 2 — Real-Time Data Authorization via Per-User OAuth 2.0 Delegation:</strong> When an end user queries Gemini Enterprise or triggers an interactive action across SharePoint or Outlook, the <strong>Federated Search &amp; Actions</strong> connectors use the OAuth 2.0 application registered in Microsoft Entra ID ( that we will name “gemini-enterprise-sharepoint-connector” in this guide) to call the <strong>Microsoft Graph REST API</strong> and <strong>M365 Search APIs</strong> directly <strong>on behalf of that signed-in user</strong>.</li><li><strong>Native Source ACL Enforcement (Zero Privilege Escalation):</strong> Because all API calls use <strong>Delegated permissions</strong> (AllSites.Read, Mail.Read, Calendars.ReadWrite, Contacts.ReadWrite, User.Read) rather than tenant-wide background crawler credentials, Microsoft Entra ID, SharePoint Online, and Exchange Online evaluate the user’s native access control lists (ACLs) in real time at query execution. Users can only discover, summarize, or act upon SharePoint sites, files, emails, and calendar events they already have permission to access in Microsoft 365.</li></ul><h4>Federated Search vs. Data Ingestion connectors: Key Tradeoffs and Why We Recommend Federated Search</h4><p>When configuring a Microsoft SharePoint or Microsoft Outlook Data Store in the Gemini Enterprise Admin Console, you are presented with two connector modes: <strong>Federated search (recommended)</strong> and <strong>Data ingestion</strong>. While Data Ingestion crawls and copies external content into a Google Cloud index, <strong>Federated Search</strong> queries Microsoft 365 APIs live at runtime. Google Cloud now recommends <strong>Federated Search</strong> as the default pattern for Microsoft 365 integrations based on the following architectural tradeoffs:</p><ul><li><strong>Identity &amp; ACL Simplicity:<br>- Federated Search (Recommended):</strong> Works directly with <strong>Google Identity</strong> (or any configured IdP) via per-user OAuth 2.0 delegated tokens. Requires <strong>no Workforce Identity Federation (WIF)</strong> setup and <strong>no SCIM group syncing</strong> into Google Cloud, and imposes no artificial limits on the number of readers per document.<br>- <strong>Data Ingestion:</strong> Strictly requires configuring <strong>Microsoft Entra ID with Workforce Identity Federation (WIF)</strong> so Google Cloud can ingest and evaluate Entra ID group ACLs against an indexed copy of the data (and caps SharePoint document ACLs at 3,000 reader principals per document). Furthermore, changing your identity provider later requires deleting and recreating all ingested data stores.</li><li><strong>Security Posture &amp; Least-Privilege Permissions:<br>- Federated Search (Recommended):</strong> Requires only <strong>Delegated</strong> API scopes (AllSites.Read, Mail.Read, Calendars.ReadWrite, Contacts.ReadWrite) with administrator consent. The connector never holds more access than the individual signed-in user.<br>- <strong>Data Ingestion:</strong> Requires high-privilege, tenant-wide <strong>Application / Full Control</strong> permissions (such as Sites.FullControl.All across SharePoint and tenant-wide Mail.Read, GroupMember.Read.All, and User.Read.All across all mailboxes) so background indexing jobs can crawl every site and mailbox — a frequent blocker for enterprise security and M365 governance teams.</li><li><strong>Data Residency, Duplication &amp; Storage Governance:<br>- Federated Search (Recommended):</strong> <strong>Zero data duplication.</strong> Corporate emails, attachments, calendar items, and SharePoint documents stay 100% inside Microsoft 365 and are never copied into a secondary search index in Google Cloud.<br>- <strong>Data Ingestion:</strong> Copies and stores full text and metadata snapshots inside Google Cloud Discovery Engine storage, duplicating sensitive M365 data across clouds and incurring additional indexing storage costs.</li><li><strong>Data Freshness &amp; Throttling Resilience:<br>- Federated Search (Recommended):</strong> <strong>Real-time freshness.</strong> Newly arrived emails, updated meeting invites, newly uploaded SharePoint files, and permission changes take effect immediately on the very next user query.<br>- <strong>Data Ingestion:</strong> Subject to full and incremental crawl intervals, sync latency, and strict Microsoft Graph ingestion rate limits (for example, Outlook data ingestion is throttled at 10,000 API requests per 10-minute window).</li><li><strong>Interactive Agentic Actions:<br>- Federated Search (Recommended):</strong> Natively supports interactive <strong>Actions</strong> executed on behalf of the user (such as sending/forwarding/moving Outlook emails, creating/updating calendar events and contacts, downloading mail attachments, and executing SharePoint actions).<br>- <strong>Data Ingestion:</strong> Built for passive, read-only indexing and retrieval over periodically synced snapshots.</li><li><strong>Mobile App &amp; Gemini Notebooks sharing: </strong><br>- At the time of this publication, sharing Gemini Notebooks is not supported with WIF, nor is the Gemini Enterprise Mobile app, so if your use case involves either of these, your only option is to use Federated Connectors.</li><li><strong>When to Still Consider Data Ingestion (Deep Document Parsing Tradeoff):<br>- </strong>Because Federated Search delegates retrieval to Microsoft 365’s live search APIs at query time, it relies on Microsoft Search’s native indexing rather than running Google Cloud’s offline <strong>Layout Parser and OCR pipeline</strong> over every document in advance. If your primary workload requires deep optical character recognition (OCR) or structural layout extraction over large volumes of complex, multi-column scanned PDFs stored in SharePoint, <strong>Data Ingestion</strong> provides deeper offline document parsing. For virtually all other enterprise M365 search, grounding, and assistant workflows, <strong>Federated Search is the recommended choice</strong>.</li></ul><h4>Prerequisites for User Federation in This Tutorial</h4><p>Before walking through the step-by-step configuration, ensure your environment meets these prerequisites across Identity, Google Cloud, and Microsoft 365:</p><ul><li><strong>Identity &amp; User Federation Prerequisites:<br>- Google Identity Configured in Gemini Enterprise:</strong> In the Google Cloud Console under <strong>Gemini Enterprise &gt; Settings &gt; Authentication</strong>, confirm that <strong>Google Identity</strong> is enabled as your identity provider.<br>- <strong>Aligned User Email / UPN:</strong> End users signing into Gemini Enterprise with their Google Identity (Cloud Identity or Google Workspace account) should have an email address that matches their Microsoft 365 <strong>User Principal Name (UPN)</strong> and Exchange Online mailbox address, and must be able to complete a one-time OAuth 2.0 user sign-in flow when first connecting their M365 account.</li><li><strong>Google Cloud &amp; Gemini Enterprise Prerequisites:<br>- Active Gemini Enterprise App:</strong> A Google Cloud project with the <strong>Gemini Enterprise (Discovery Engine) API</strong> enabled and an active Gemini Enterprise application created.<br>- <strong>Administrator &amp; End-User IAM Roles:</strong> The administrator setting up the connectors needs the <strong>Discovery Engine Admin</strong> (roles/discoveryengine.admin) role in Google Cloud, and end users accessing the assistant need the <strong>Gemini Enterprise User</strong> (roles/discoveryengine.agentspaceUser) role (or if you need fine-grained access control to the connectors, the proper User role in each connector for those users or groups and also enable Resource Access Control enabled in GE Settings, this setting is out of scope for this tutorial).</li><li><strong>Microsoft Entra ID &amp; Microsoft 365 Prerequisites:<br>- Microsoft 365 Online Tenant:</strong> An active Microsoft 365 subscription with <strong>SharePoint Online</strong> and <strong>Exchange Online</strong> (user mailboxes must reside in <strong>Exchange Online</strong> rather than on-premises Hybrid Exchange so they can be queried via the Microsoft Graph REST API).<br>- <strong>Entra ID Global Administrator (or App + SharePoint Admin) Access:</strong> Administrator access to the <strong>Microsoft Entra Admin Center</strong> (https://entra.microsoft.com) and <strong>Microsoft 365 Admin Center</strong> (https://admin.microsoft.com) to register the OAuth 2.0 application, generate a Client Secret, and click <strong>Grant admin consent</strong> for the delegated Microsoft Graph and SharePoint API permissions.</li></ul><h4>Architecture Overview of This Tutorial’s Approach</h4><p>The diagram below illustrates the end-to-end federated architecture we will build in this tutorial. End users authenticate to the <strong>Gemini Enterprise App</strong> using <strong>Google Identity </strong>(this might not be required if you already have federated your Entra users using Google Cloud Directory Sync, for example), while the <strong>SharePoint</strong> (sharepoint-connector) and <strong>Outlook</strong> (outlook-connector) Federated Data Stores communicate with <strong>Microsoft SharePoint Online</strong> and <strong>Microsoft Outlook / Exchange Online</strong> in real time through our <strong>Microsoft Entra ID OAuth 2.0 App Registration</strong> using per-user delegated permissions.</p><p><strong>Architecture Diagram — Gemini Enterprise Federated Search &amp; Actions with Microsoft Entra ID OAuth 2.0 User Delegation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n1Hp5q3pL98mgMQC3dHHaw.png" /></figure><h4>Starting the Connector Setup in the Gemini Enterprise Admin Console</h4><blockquote>Note: Some of the screenshots provided are for the Outlook connector, but they work similarly for the Sharepoint connector. you would need to do the connector setup twice, one for Sharepoint, one for the Outlook connector.</blockquote><ul><li><strong>Console</strong>: <strong>Google Cloud Console — Gemini Enterprise Admin Console</strong> (https://console.cloud.google.com)</li><li><strong>Where to navigate</strong>: Gemini Enterprise (left sidebar) &gt; Data stores &gt; + Create data store &gt; Microsoft SharePoint &gt; Step 2: Data</li></ul><p>When you begin creating a Microsoft 365 Data Store in the <strong>Gemini Enterprise Admin Console</strong>:</p><ol><li>Open <strong>Gemini Enterprise</strong> in the Google Cloud Console and select <strong>Data stores</strong> from the left-hand navigation menu (above <em>Manage users</em> and <em>Settings</em>).</li><li>Click <strong>+ Create data store</strong> and choose <strong>Microsoft SharePoint</strong> (or <strong>Microsoft Outlook</strong>) in <strong>Step 1: Source</strong>.</li><li>In <strong>Step 2: Data (Specify the SharePoint source for your data store)</strong>, expand <strong>1. Connector mode</strong> and select <strong>Federated search (recommended)</strong> instead of <em>Data ingestion</em>, then click <strong>Continue</strong>.</li><li>Next, notice the collapsed configuration sections right below <em>Connector mode</em>: <strong>2. Authentication settings</strong>, <strong>3. Destinations</strong>, <strong>4. Advanced options</strong>, and <strong>5. Entities to search</strong>. To complete <strong>2. Authentication settings</strong>, Gemini Enterprise requires your Microsoft Entra ID OAuth 2.0 credentials (Client ID, Client Secret, Tenant ID, and SharePoint Instance URI). Before we can fill out those fields, let’s switch to the <strong>Microsoft Entra Admin Center</strong> to create and retrieve them.</li></ol><p><strong>Console: Google Cloud Console — Gemini Enterprise Admin Console (Data stores &gt; Create data store &gt; Step 2: Data — Microsoft SharePoint):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U-XvFUcacq2tRdDNWgDTMw.png" /></figure><h3>Part 1: Set Up Gemini Enterprise as an OAuth 2.0 Application in Microsoft Entra ID</h3><p>To complete the <strong>Authentication settings</strong> step in the Gemini Enterprise connector wizard, you first need to register Gemini Enterprise as an OAuth 2.0 application in <strong>Microsoft Entra ID</strong> and obtain the following credentials:</p><ul><li><strong>Entra ID’s Tenant ID</strong> (Directory (tenant) ID)</li><li><strong>Client ID</strong> (Application (client) ID)</li><li><strong>Client Secret</strong> (Value)</li><li><strong>SharePoint Instance URI</strong> (https://&lt;your-domain&gt;.sharepoint.com)</li></ul><p>For the complete prerequisite reference, see <a href="https://docs.cloud.google.com/gemini/enterprise/docs/connectors/ms-sharepoint/third-party-config">Configure Microsoft SharePoint for Gemini Enterprise</a>.</p><h4>Step 1: Locate Your Tenant ID and Open App Registrations in the Microsoft Entra Admin Center</h4><ul><li><strong>Console</strong>: <strong>Microsoft Entra Admin Center</strong> (https://entra.microsoft.com)</li><li><strong>Where to navigate</strong>: Left navigation sidebar &gt; Entra ID &gt; Overview and Entra ID &gt; App registrations</li></ul><p>Follow these steps in the <strong>Microsoft Entra Admin Center</strong>:</p><ol><li>Sign in to the <a href="https://entra.microsoft.com/">Microsoft Entra Admin Center</a> using an account with <strong>Global Administrator</strong> privileges (as indicated by the Global Administrator badge on the right card below).</li><li>On the <strong>Microsoft Entra</strong> overview dashboard (Entra ID &gt; Overview), locate the organization card on the left showing your <strong>Tenant ID</strong> and <strong>Primary domain</strong>. Click the copy icon next to <strong>Tenant ID</strong> to copy your Directory UUID.</li><li>In the left-hand navigation sidebar under <strong>Entra ID</strong>, click <strong>App registrations</strong> (highlighted in the navigation menu below), and then click <strong>+ New registration</strong> at the top of the screen.</li><li>In the <strong>Register an application</strong> dialog:<br>- <strong>Name</strong>: Enter a recognizable name for your integration, such as gemini-enterprise-sharepoint-connector (you can reuse this single Entra ID app registration for both the SharePoint and Outlook connectors).<br>- <strong>Supported account types</strong>: Select <strong>Accounts in this organizational directory only (Single tenant)</strong>.<br>- <strong>Redirect URI</strong>: Select <strong>Web</strong> as the platform and add the required Google Cloud OAuth callback URIs (https://vertexaisearch.cloud.google.com/console/oauth/sharepoint_oauth.html for SharePoint, <a href="https://vertexaisearch.cloud.google.com/console/oauth/default_oauth.html">https://vertexaisearch.cloud.google.com/console/oauth/default_oauth.html</a> for Outlook, and <a href="https://vertexaisearch.cloud.google.com/oauth-redirect">https://vertexaisearch.cloud.google.com/oauth-redirect</a> under <em>Manage &gt; Authentication</em>).<br>- Click <strong>Register</strong>, and copy the <strong>Application (client) ID</strong> displayed on the newly created app’s <strong>Overview</strong> screen.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TuUWCHcaeE94kmBKL_Ax_g.png" /></figure><p><strong>Console: Microsoft Entra Admin Center (Entra ID &gt; Overview &amp; Entra ID &gt; App registrations in the left sidebar):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LENYjOo9XtcYJUfJhsog9w.jpeg" /></figure><h4>Understanding the Four Credentials Required by Gemini Enterprise</h4><p>Before moving to the next screens, let’s review the exact four parameters you are collecting for the Gemini Enterprise connectors:</p><ul><li><strong>Client ID</strong>: The unique <strong>Application (client) ID</strong> (UUID) generated on your app’s <strong>Overview</strong> blade in the <strong>Microsoft Entra Admin Center</strong> (Entra ID &gt; App registrations &gt; &lt;your-app&gt; &gt; Overview).</li><li><strong>Client secret</strong>: The confidential <strong>Value</strong> string created under App registrations &gt; &lt;your-app&gt; &gt; Manage &gt; Certificates &amp; secrets (detailed in Step 3 below).</li><li><strong>Tenant ID</strong>: Your Microsoft 365 / Entra ID <strong>Directory (tenant) ID</strong> (UUID), which uniquely identifies your organization’s tenant.</li><li><strong>Instance URI</strong>: Your organization’s root SharePoint Online URL (for example, https://&lt;your-domain&gt;.sharepoint.com), required when configuring the SharePoint connector.</li></ul><p>You will also configure the Microsoft Graph and SharePoint API permissions with the consent of a Microsoft SharePoint / Global Administrator.</p><h4>Step 2: Retrieve Your Tenant ID from the Microsoft 365 Admin Center (Alternative Method)</h4><ul><li><strong>Console</strong>: <strong>Microsoft 365 Admin Center</strong> (https://admin.cloud.microsoft)</li><li><strong>Where to navigate</strong>: Home &gt; Setup &gt; Organization information (or open the direct link: <a href="https://admin.cloud.microsoft/?#/featureexplorer/:/Settings/L1/OrganizationInformation">Organization Information in the M365 Admin Center</a>)</li></ul><p>In addition to the Microsoft Entra Overview page shown in Step 1, you can also look up your <strong>Tenant ID</strong> and <strong>Default domain</strong> directly in the <strong>Microsoft 365 Admin Center</strong>:</p><ol><li>Open the <a href="https://admin.cloud.microsoft/?#/featureexplorer/:/Settings/L1/OrganizationInformation">Organization information panel</a> in the <strong>Microsoft 365 admin center</strong>.</li><li>In the <strong>Organization information</strong> flyout drawer on the right, locate <strong>Default domain</strong> (YOUR_DOMAIN) and <strong>Tenant ID</strong> (highlighted by the red box and arrow below).</li><li>Copy your <strong>Tenant ID</strong> and save it alongside your <strong>Client ID</strong>.</li></ol><p><strong>Console: Microsoft 365 Admin Center (Home &gt; Setup &gt; Organization information flyout panel — Copy your Tenant ID):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Qx9Xi4D8caWA1O-zLKFOA.jpeg" /></figure><h4>Step 3: Create and Copy the Client Secret in the Microsoft Entra Admin Center</h4><ul><li><strong>Console</strong>: <strong>Microsoft Entra Admin Center</strong> (https://entra.microsoft.com)</li><li><strong>Where to navigate</strong>: Home &gt; App registrations &gt; gemini-enterprise-sharepoint-connector &gt; Manage (left sidebar) &gt; Certificates &amp; secrets</li></ul><p>Once you have registered Gemini Enterprise as an OAuth 2.0 client application in Microsoft Entra ID (and copied its <strong>Application (client) ID</strong> from the app’s <em>Overview</em> page), generate its client secret:</p><ol><li>In the left navigation menu of your App Registration (gemini-enterprise-sharepoint-connector), look under <strong>Manage</strong> and click <strong>Certificates &amp; secrets</strong>.</li><li>Select the <strong>Client secrets</strong> tab and click <strong>+ New client secret</strong>.</li><li>Enter a clear <strong>Description</strong> (for example, Secret GE — client), choose an expiration period, and click <strong>Add</strong>.</li></ol><blockquote><strong>What to retrieve (Critical!)</strong>: Immediately copy the string under the <strong>Value</strong> column (highlighted by the red <strong>“Copy and store this!”</strong> arrow below — do <strong>not</strong> copy the <em>Secret ID</em> UUID). Store this secret value somewhere safe right away, because Microsoft Entra ID masks the <strong>Value</strong> permanently as soon as you leave or refresh this screen.</blockquote><p><strong>Console: Microsoft Entra Admin Center (Home &gt; App registrations &gt; gemini-enterprise-sharepoint-connector &gt; Certificates &amp; secrets):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ipJn2BmmHIAazLYsQGCwHw.jpeg" /></figure><h4>Step 4: Enable the Required API Permissions and Grant Admin Consent in Microsoft Entra ID</h4><ul><li><strong>Console</strong>: <strong>Microsoft Entra Admin Center</strong> (https://entra.microsoft.com)</li><li><strong>Where to navigate</strong>: Home &gt; App registrations &gt; gemini-enterprise-sharepoint-connector &gt; Manage (left sidebar) &gt; API permissions</li></ul><p>Next, configure the delegated API permissions required for Gemini Enterprise to authenticate users and access both Microsoft Outlook (via Microsoft Graph) and Microsoft SharePoint:</p><ol><li>In the left-hand menu of your App Registration under <strong>Manage</strong>, select <strong>API permissions</strong>.</li><li>Click <strong>+ Add a permission</strong> under <strong>Configured permissions</strong>.</li><li><strong>Add Microsoft Graph Delegated Permissions (10 permissions for User Profile &amp; Outlook Mail, Calendar, and Contacts)</strong>:</li></ol><ul><li>Select <strong>Microsoft Graph</strong> -&gt; <strong>Delegated permissions</strong>, then search for and select the following 10 permissions:</li></ul><blockquote>Calendars.Read (<em>Read user calendars</em>)</blockquote><blockquote>Calendars.Read.Shared (<em>Read user and shared calendars</em>)</blockquote><blockquote>Calendars.ReadWrite (<em>Have full access to user calendars</em>)</blockquote><blockquote>Contacts.Read (<em>Read user contacts</em>)</blockquote><blockquote>Contacts.ReadWrite (<em>Have full access to user contacts</em>)</blockquote><blockquote>email (<em>View users’ email address</em>)</blockquote><blockquote>Mail.Read (<em>Read user mail</em>)</blockquote><blockquote>Mail.Read.Shared (<em>Read user and shared mail</em>)</blockquote><blockquote>Mail.Send (<em>Send mail as a user</em>)</blockquote><blockquote>User.Read (<em>Sign in and read user profile</em>)</blockquote><ul><li>Click <strong>Add permissions</strong>.</li></ul><p><strong>4. Add Microsoft SharePoint Delegated Permissions (1 permission for SharePoint Site Collections)</strong>:</p><ul><li>Click <strong>+ Add a permission</strong> again -&gt; choose <strong>SharePoint</strong> -&gt; <strong>Delegated permissions</strong>.</li><li>Expand <strong>AllSites</strong>, check <strong>AllSites.Read</strong> (<em>Read items in all site collections</em>), and click <strong>Add permissions</strong>.</li></ul><p><strong>5. Grant Tenant-Wide Admin Consent (Crucial Step!)</strong>:</p><ul><li>Back on the <strong>API permissions</strong> screen, click <strong>✓ Grant admin consent for &lt;your-tenant&gt;</strong> (next to + Add a permission) and confirm in the dialog prompt.</li><li>Verify that every permission in the <strong>Status</strong> column displays a green checkmark (<strong>Granted for &lt;your-tenant&gt;</strong>), as shown below.</li></ul><p><strong>Console: Microsoft Entra Admin Center (Home &gt; App registrations &gt; gemini-enterprise-sharepoint-connector &gt; API permissions):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yoJMPMJdn9hpNIjdewNEuA.jpeg" /></figure><h3>Part 2: Configure the Microsoft Outlook Connector in the Gemini Enterprise Admin Console</h3><p>With your OAuth 2.0 application registered, client secret generated, and delegated API permissions granted in Microsoft Entra ID, switch back to the <strong>Google Cloud Console — Gemini Enterprise Admin Console</strong> to configure your Microsoft 365 Data Store connectors. Let’s walk through the <strong>Microsoft Outlook</strong> connector setup first (or you can resume where you left off configuring the Sharepoint connector at the beggining of the guide).</p><h4>Step 1: Select Connector Mode and Enter Authentication Settings (Step 2: Data)</h4><ul><li><strong>Console</strong>: <strong>Google Cloud Console — Gemini Enterprise Admin Console</strong> (https://console.cloud.google.com)</li><li><strong>Where to navigate</strong>: Gemini Enterprise (left navigation menu) &gt; Data stores &gt; + Create data store &gt; Select “Microsoft Outlook” in Step 1 (Source) &gt; Step 2: Data (Specify the Outlook source for your data store)</li></ul><p>On the <strong>Specify the Outlook source for your data store</strong> screen, complete the first two sub-steps:</p><ol><li><strong>Sub-step 1 — Connector mode</strong>: Select <strong>Federated search (recommended)</strong> so Gemini Enterprise queries Microsoft Graph live using the user’s identity, then click <strong>Continue</strong>.</li><li><strong>Sub-step 2 — Authentication settings</strong>: Populate the fields using the credentials you retrieved from the <strong>Microsoft Entra Admin Center</strong>:<br>-<strong> Client ID (Required)</strong>: Paste YOUR-ClientID (the Application (client) ID of the app you registered in Entra ID).<br>- <strong>Client Secret (Required)</strong>: Paste the Client Secret Value you created and copied under Certificates &amp; secrets in Entra ID.<br>- <strong>Tenant ID (Required)</strong>: Paste YOUR-Tenant ID (the Directory UUID from the Entra ID Overview or M365 Admin Center).<br>- <strong>Microsoft Outlook Environment Type</strong>: Select <strong>Standard</strong> from the dropdown.</li><li><strong>Authorize with Your M365 Admin Account</strong>: Click the login/authorize button and sign in with your Microsoft 365 administrator credentials (for example, m365-admin@&lt;your-domain&gt;). Confirm that the green banner appears at the bottom: <strong>Successfully logged in with associated identity: …</strong>.</li></ol><p><strong>Console: Google Cloud Console — Gemini Enterprise Admin Console (Create data store &gt; Step 2: Data &gt; Connector mode &amp; Authentication settings):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZGBJX63u9oM2uXON9BlYoQ.jpeg" /></figure><h4>Step 2: Configure Advanced Options (Step 2: Data — Sub-step 3)</h4><ul><li><strong>Console</strong>: <strong>Google Cloud Console — Gemini Enterprise Admin Console</strong></li><li><strong>Where to navigate</strong>: Gemini Enterprise &gt; Data stores &gt; Create data store &gt; Step 2: Data &gt; Sub-step 3: Advanced options (click <strong>Continue</strong> under <em>Authentication settings</em> and scroll down).</li></ul><p>In <strong>Sub-step 3: Advanced options</strong>, configure the tenant and cloud environment settings for Microsoft Online:</p><ol><li><strong>Enable static IP</strong>: Leave this unchecked unless your Microsoft Entra ID Conditional Access rules enforce strict IP allowlisting.</li><li><strong>Azure Tenant (Required)</strong>: Paste your Microsoft Entra Tenant ID (e.g., a00xxxxx-9999–000x-x0x0–000xx0x0xxxxx) — the same Directory UUID you copied from the Entra ID Overview or M365 Organization Information screen.</li><li><strong>Microsoft 365 Cloud Environment</strong>: Select <strong>Global</strong> from the dropdown menu.</li><li>Click <strong>Continue</strong> inside the <strong>Advanced options</strong> panel to expand <strong>Sub-step 4: Entities to search</strong>.</li></ol><p><strong>Console: Google Cloud Console — Gemini Enterprise Admin Console (Create data store &gt; Step 2: Data &gt; Sub-step 3: Advanced options):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UOkhThez-DPwxPp6zhj_sQ.jpeg" /></figure><h4>Step 3: Choose Outlook Entities to Search (Step 2: Data — Sub-step 4)</h4><ul><li><strong>Console</strong>: <strong>Google Cloud Console — Gemini Enterprise Admin Console</strong></li><li><strong>Where to navigate</strong>: Gemini Enterprise &gt; Data stores &gt; Create data store &gt; Step 2: Data &gt; Sub-step 4: Entities to search</li></ul><p>Once <strong>Authentication settings</strong> and <strong>Advanced options</strong> display blue completion checkmarks, <strong>Sub-step 4: Entities to search</strong> expands:</p><ol><li>Under <strong>Choose entities you want to include</strong> (Root &gt; All), check all four Microsoft Outlook entities that you want Gemini Enterprise to query during federated search:<br>- <strong>Mail</strong>: User emails and message threads.<br>- <strong>Mail Attachment</strong>: Files and documents attached to emails.<br>- <strong>Calendar</strong>: Calendar events, meetings, and invitations.<br>- <strong>Contact</strong>: Personal and organizational contacts stored in Outlook.</li><li>Click the blue <strong>Continue</strong> button at the bottom of the page to move to <strong>Step 3: Actions</strong>.</li></ol><p><strong>Console: Google Cloud Console — Gemini Enterprise Admin Console (Create data store &gt; Step 2: Data &gt; Sub-step 4: Entities to search):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eVYRRFh4L4mDEkKTrterKQ.png" /></figure><h4>Step 4: Select Microsoft Outlook Actions to Enable (Step 3: Actions)</h4><ul><li><strong>Console</strong>: <strong>Google Cloud Console — Gemini Enterprise Admin Console</strong></li><li><strong>Where to navigate</strong>: Gemini Enterprise &gt; Data stores &gt; Create data store &gt; Step 3: Actions (Select Microsoft Outlook actions to enable)</li></ul><p>After clicking <strong>Continue</strong> from the <strong>Data</strong> step, the wizard advances to <strong>Step 3: Actions</strong> in the left-hand stepper. Because we granted Mail.Send, Calendars.ReadWrite, and Contacts.ReadWrite delegated permissions in Microsoft Entra ID earlier, Gemini Enterprise (and any custom agents using this connector) can execute interactive actions on behalf of the user:</p><ol><li>Check <strong>Select all actions</strong> (or individually select the specific actions allowed by your organization):<br>- <strong>Create contact</strong>: Creates a new Outlook contact.<br>- <strong>Create calendar event</strong>: Schedules new Outlook calendar events.<br>- <strong>Download attachments</strong>: Downloads one or more attachments from a specified email message.<br>- <strong>Forward email</strong>: Forwards an email to a new recipient.<br>- <strong>Move email</strong>: Moves an email to a specific folder.<br>- <strong>Send email</strong>: Drafts an email to be sent from the user’s Outlook account.<br>- <strong>Update contact</strong>: Updates an existing Outlook contact.<br>- <strong>Update calendar event</strong>: Updates an existing Outlook calendar event.</li><li>Click <strong>Continue</strong> at the bottom of the screen to proceed to <strong>Step 4: Configuration</strong>.</li></ol><p><strong>Console: Google Cloud Console — Gemini Enterprise Admin Console (Create data store &gt; Step 3: Actions — Select Microsoft Outlook actions to enable):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*XLbvDW_ycVmtRFPrXAiQgQ.png" /></figure><h4>Step 5: Name and Create Your Outlook Data Connector (Step 4: Configuration)</h4><ul><li><strong>Console</strong>: <strong>Google Cloud Console — Gemini Enterprise Admin Console</strong></li><li><strong>Where to navigate</strong>: Gemini Enterprise &gt; Data stores &gt; Create data store &gt; Step 4: Configuration (Configure your data connector)</li></ul><p>In the final step of the wizard (<strong>4. Configuration</strong>), complete the following fields:</p><ol><li><strong>Location of your data connector</strong>: Verify that the <strong>Multi-region</strong> matches your Gemini Enterprise app location (for example, global (Global)).</li><li><strong>Your data connector name</strong>: Enter a recognizable name in the <strong>Data connector name (Required)</strong> field, such as outlook-connector. Note the auto-generated resource ID right below the field (in this case ID: outlook-connector_9999999999990), which cannot be changed after creation.</li><li><strong>Sensitive data protection policy (Optional)</strong>: If your organization enforces Cloud DLP / Sensitive Data Protection inspection policies, provide the full resource name (projects/{project}/locations/{location}/contentPolicies/{policy}); otherwise, leave it blank.</li><li>Click <strong>Create</strong> at the bottom of the page to provision your Microsoft Outlook connector.</li></ol><p><strong>Console: Google Cloud Console — Gemini Enterprise Admin Console (Create data store &gt; Step 4: Configuration — Configure your data connector):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VUbHQfvML6WN7sVCDTnvAA.jpeg" /></figure><h3>Part 3: Complete the Microsoft SharePoint Connector in the Gemini Enterprise Admin Console</h3><p>Now that your Microsoft Outlook connector is provisioned, you can complete the <strong>Microsoft SharePoint</strong> connector we initiated at the start of this tutorial using the exact same Microsoft Entra ID OAuth 2.0 application credentials (gemini-enterprise-sharepoint-connector):</p><ol><li><strong>Open the SharePoint Connector Wizard</strong>: In the <strong>Google Cloud Console — Gemini Enterprise Admin Console</strong>, navigate to <strong>Gemini Enterprise &gt; Data stores &gt; + Create data store</strong>, select <strong>Microsoft SharePoint</strong> under <strong>Step 1: Source</strong>, and select <strong>Federated search (recommended)</strong> under <strong>Step 2: Data &gt; 1. Connector mode</strong> (as shown in the first screenshot of this article).</li><li><strong>Configure Authentication Settings (2. Authentication settings)</strong>:<br>- <strong>Client ID</strong>: Paste the <strong>Application (client) ID</strong> from your Microsoft Entra ID App Registration.<br>- <strong>Client Secret</strong>: Paste the <strong>Client Secret Value</strong> generated under <em>Certificates &amp; secrets</em>.<br>- <strong>Tenant ID</strong>: Paste your <strong>Microsoft Entra Tenant ID</strong> (UUID).<br>- <strong>Instance URI</strong>: Enter your organization’s root SharePoint Online URL in the format https://&lt;your-domain&gt;.sharepoint.com (for example, <a href="https://contoso.sharepoint.com)./">https://contoso.sharepoint.com).</a><br>- Click the login/authorization button, sign in with your Microsoft 365 administrator account, and verify that the green <strong>Successfully logged in with associated identity</strong> banner appears.</li><li><strong>Configure Destinations, Advanced Options &amp; Entities (3. Destinations, 4. Advanced options, 5. Entities to search)</strong>: Specify the SharePoint site collections to include, enter your <strong>Azure Tenant</strong> UUID and <strong>Global</strong> environment under <strong>Advanced options</strong>, and select the SharePoint entities to search.</li><li><strong>Configure Actions &amp; Create (Step 3: Actions &amp; Step 4: Configuration)</strong>: Enable any desired SharePoint actions, enter a connector name (such as sharepoint-connector) in <strong>Step 4: Configuration</strong>, and click <strong>Create</strong>.</li><li><strong>Attach Connectors to Your Gemini Enterprise App</strong>: In the left-hand navigation menu of the <strong>Gemini Enterprise Admin Console</strong>, click <strong>Apps</strong>, select your Gemini Enterprise application, and link both outlook-connector and sharepoint-connector as active Data Stores.</li></ol><h3>Congratulations!</h3><p>You have successfully set up the Microsoft 365 connectors for your Gemini Enterprise App! By following this guide, you have established a secure, federated integration that allows your organization to query, discover, synthesize, and take action on corporate data across both Google Cloud and Microsoft 365 environments.</p><h3>What we’ve covered</h3><ul><li><strong>App Registration in Microsoft Entra ID</strong>: Registered Gemini Enterprise as an OAuth 2.0 application in the <strong>Microsoft Entra Admin Center</strong> and retrieved critical credentials, including the <strong>Tenant ID</strong> (via both the Entra ID Overview screen and the <strong>Microsoft 365 Admin Center</strong>), <strong>Application (Client) ID</strong>, and <strong>Client Secret Value</strong>.</li><li><strong>API Permissions &amp; Admin Consent</strong>: Configured the required delegated permissions for <strong>Microsoft Graph</strong> (10 permissions covering Mail, Calendars, Contacts, and User profiles) and <strong>SharePoint</strong> (AllSites.Read), and granted tenant-wide administrator consent so the Gemini Enterprise App can securely authenticate and act on behalf of users.</li><li><strong>Microsoft Outlook Connector Setup</strong>: Created and configured the outlook-connector Data Store in the <strong>Gemini Enterprise Admin Console</strong>, selecting <strong>Federated search</strong> mode, authenticating with Entra ID credentials, configuring <strong>Advanced options</strong> (Azure Tenant and Global cloud environment), selecting all four <strong>Entities to search</strong> (<em>Mail</em>, <em>Mail Attachment</em>, <em>Calendar</em>, and <em>Contact</em>), and enabling all 8 interactive <strong>Outlook Actions</strong> (creating/updating events and contacts, sending/forwarding/moving emails, and downloading attachments).</li><li><strong>Microsoft SharePoint Connector Setup</strong>: Configured the <strong>Microsoft SharePoint</strong> Federated search connector in the <strong>Gemini Enterprise Admin Console</strong> using the registered Entra ID application credentials and SharePoint <strong>Instance URI</strong> to enable seamless cross-platform search over SharePoint site collections.</li></ul><h3>Useful Documentation</h3><ul><li><strong>Learn about Gemini Enterprise</strong>: <a href="https://docs.cloud.google.com/gemini/enterprise/docs">https://docs.cloud.google.com/gemini/enterprise/docs</a></li><li><strong>SharePoint Federated Connector in Gemini Enterprise</strong>: <a href="https://docs.cloud.google.com/gemini/enterprise/docs/connectors/ms-sharepoint/third-party-config">https://docs.cloud.google.com/gemini/enterprise/docs/connectors/ms-sharepoint/third-party-config</a></li><li><strong>Outlook Federated Connector in Gemini Enterprise</strong>: <a href="https://docs.cloud.google.com/gemini/enterprise/docs/connectors/ms-outlook/third-party-config">https://docs.cloud.google.com/gemini/enterprise/docs/connectors/ms-outlook/third-party-config</a></li></ul><h4>Manual Last Updated November 5, 2026</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18800d1409ed" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/gemini-enterprise-series-enable-ms-sharepoint-outlook-connectors-in-less-than-10-minutes-18800d1409ed">Gemini Enterprise Series: Enable MS SharePoint &amp; Outlook Connectors in less than 10 minutes</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Security in Google Cloud series — Part 1: Physical data encryption of sensitive data using…]]></title>
            <link>https://medium.com/google-cloud/data-security-in-google-cloud-series-part-1-physical-data-encryption-of-sensitive-data-using-826ca7abd11d?source=rss-c83442440f33------2</link>
            <guid isPermaLink="false">https://medium.com/p/826ca7abd11d</guid>
            <category><![CDATA[cloud-dlp]]></category>
            <category><![CDATA[gcp-security-operations]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[data-security]]></category>
            <category><![CDATA[cloud-kms]]></category>
            <dc:creator><![CDATA[Daniel Villegas]]></dc:creator>
            <pubDate>Wed, 07 Jun 2023 01:08:17 GMT</pubDate>
            <atom:updated>2023-06-08T18:33:33.548Z</atom:updated>
            <content:encoded><![CDATA[<h3>Data Security in Google Cloud series — Part 1: Physical data encryption of sensitive data using Cloud DLP and KMS</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hhkAtxaBVx_pFbDQwCwtlg.png" /></figure><p>Many companies that are uploading their data to the cloud, are being required to do so securely and make sure that any data containing sensitive information such as Personally Identifiable Information (PII) is properly handled and de-identified in the cloud by using different data securitization techniques like tokenization, masking or encryption. The use of encryption is becoming increasingly important as businesses and individuals collect and store more sensitive data. Encryption can help to protect this data from unauthorized access, use, or disclosure. As the number of governments around the world enforcing these rules through legislation increases, adopting a practice of inspecting data for PII and properly handling and securing it in the cloud becomes of paramount importance. This article provides an example of how to use Google Cloud’s Data Loss Prevention and Key Management System services within a data pipeline created with either Cloud Data Fusion or Dataflow, to inspect a field in a file in Cloud Storage for a National ID (in this case a Chilean National ID or “Cédula De Identidad”), and encrypt those IDs prior to inserting them into a table in BigQuery. The data is physically encrypted in the table so that the sensitive information is secured even in the unlikely event of a data exfiltration, and can later be reversed to its original value, by using the same KMS key.</p><h3>Overview</h3><p><a href="https://cloud.google.com/dlp">Data Loss Prevention (DLP)</a> is Google Cloud’s Data Loss Prevention (DLP) is a suite of services that helps you find, classify, and protect sensitive data across your Google Cloud resources, on streams of data, structured text data stored in files or tables in BigQuery, even on unstructured data such as images. DLP can help you comply with data protection regulations, prevent data breaches, and ensure the security of your data.</p><p>DLP has a variety of features to help you protect your data, these features include:</p><ul><li><strong>Inspection:</strong> DLP can scan your data for sensitive data using a variety of methods, including dictionaries, regular expressions, and contextual elements.</li><li><strong>Classification:</strong> DLP can classify sensitive data into categories, such as financial data, PII data, and intellectual property.</li><li><strong>De-identification:</strong> DLP can remove sensitive data from your data without impacting its utility. This can be done by redacting, masking, or encrypting the data.</li></ul><p>DLP uses a variety of methods to identify sensitive data, including:</p><ul><li>Pattern matching</li><li>Machine learning</li><li>Custom dictionaries</li></ul><p>Also, Google Cloud DLP provides a predefined set of categories of sensitive information that can be used to create DLP policies, that are called Infotypes. Google has already setup over 150 infotypes that can identify sensitive data including things like credit card numbers, Social Security numbers, National IDs, and email addresses and provided for you out-of-the-box.</p><p>Once sensitive data is identified, DLP can take a variety of actions to protect it, such as data redaction, format-preserving and other types of encryption, data masking, security policies, etc.</p><p><a href="https://cloud.google.com/security-key-management">Cloud Key Management Service (KMS)</a> is Google’s cloud-based key management service that makes it easy to manage encryption keys for your cloud resources. KMS provides a single place to store, rotate, and audit your encryption keys, and it integrates with other Google Cloud services to make it easy to use encryption in your applications. Cloud Key Management, allows the creation and use of Software based keys that can be managed automatically for you by Google, or keys managed by you (Customer-managed Encryption keys or CMEK), Hardware based keys (with HSM as a service), and external key managers to import keys created and managed on a third-party key management system and use them in GCP.</p><p><a href="https://cloud.google.com/data-fusion">Cloud Data Fusion</a> is Google Cloud’s native low/no code solution for creating ETL/ELT pipelines at any scale. It makes it easy to create and run data wrangling and transformation pipelines by abstracting all the complexity of writing code to run on top of Cloud Dataproc cluster and providing the user with a point and click visual user interface instead.</p><p><a href="https://cloud.google.com/dataflow">Dataflow</a> is a fully managed service that provides a unified experience for both batch and streaming data processing. It uses Apache Beam, a unified model for large-scale data processing, to run your pipelines on Google Cloud Platform. Dataflow abstracts away the complexity of managing and scaling infrastructure, so you can focus on writing your pipelines.</p><p>Both Data Fusion and Dataflow services described above can leverage the KMS and DLP APIs to create cloud-native, secure data pipelines, with built-in data scanning and data de-identification of sensitive data.</p><h3>What we will cover</h3><ol><li>Learn how to use Cloud Data Loss Prevention to Inspect and Redact sensitive data by leveraging Inspection and De-Identification templates.</li><li>Learn how to use a KMS-generated symmetric encryption key to encrypt the sensitive data detected by DLP.</li><li>Create a pipeline that reads data containing sensitive information from a file in a Cloud Storage bucket, inspects that data for sensitive information defined in a DLP Inspection template, encrypts the data with an encryption key determined by a DLP De-identification template, and loads the data with the encrypted column in a BigQuery table using both Cloud Data Fusion and Dataflow. For this exercise we will create two data pipelines that perform the same task, a batch pipeline in Data Fusion and Streaming job in Dataflow just to exemplify how to perform this task with any of these tools. For your particular use case, you may choose which Data transformation tool to choose.</li></ol><h4>This is how the architecture for this solution looks like:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gmt-uu7OIwZaIdCxTvNUag.png" /></figure><h3>GCP Services used for the solution:</h3><ul><li>Google Cloud Data Loss Prevention.</li><li>Google Cloud Key Management Service.</li><li>Google Cloud Data Fusion.</li><li>Google Cloud Dataflow.</li><li>Google Cloud Storage.</li><li>Google BigQuery</li></ul><h3>Setup and requirements</h3><p><strong>Note: A working instance of Cloud Data Fusion is required for the later part of this exercise. You may find an example of how to create a Private instance in a previous article I published here:</strong> <a href="https://medium.com/google-cloud/connect-private-data-fusion-instance-with-a-private-cloud-sql-instance-using-cloudsql-proxy-caddf4795ac6">https://medium.com/google-cloud/connect-private-data-fusion-instance-with-a-private-cloud-sql-instance-using-cloudsql-proxy-caddf4795ac6</a></p><p><strong>You only need the Data Fusion instance, no need to create the Cloud SQL instance or the SQL proxy mentioned in that article for this exercise.</strong></p><p>Run the following command in Cloud Shell:</p><pre>gcloud services enable cloudkms.googleapis.com \<br>cloudscheduler.googleapis.com \<br>datafusion.googleapis.com \<br>dataflow.googleapis.com \<br>compute.googleapis.com \<br>datapipelines.googleapis.com \<br>dlp.googleapis.com</pre><p>Set initial environment variables by running the following command in cloud shell:</p><pre>export PROJECT_ID=$(gcloud config get-value project)</pre><h3>Steps:</h3><ol><li>Create a bucket in GCS and upload a file with a column containing sensitive PII data (In this case it’s Chilean Nation ID numbers, called “CHILE_CDI_NUMBER” infotype in DLP)</li><li>Create KMS keyring and key (Using CMEK)</li><li>Create the Inspection Template in DLP referencing the infotypes you want DLP to detect.</li><li>Create a wrapped key with the KMS key and create the De-Identification Template in DLP referencing that KMS key.</li><li>Use the Dataflow template to redact sensitive data in a file within a GCS bucket, inspect it using the Inspection Template, redact the detections by encrypting the data using the KMS encryption key, and uploading the results to a BigQuery table.</li><li>Perform the same tasks as Step #5, but using the DLP plugin in Data Fusion.</li></ol><h3><strong>1) Bucket in GCS and file to be de-identified:</strong></h3><p>We just create a storage bucket named “datos_dlp” (remember the bucket name must be unique across GCP ) that will hold the CSV file we will use in the example:</p><pre>gsutil mb gs://datos_dlp/</pre><p>The sample file is a simple .csv file containing a list of Chilean public, government owned companies, and contains 3 columns:</p><ul><li><strong>CDI:</strong> Chilean National ID (In Chile both, citizens as well as private and public companies have a National ID called “Cédula nacional De Identidad”).</li><li><strong>NOMBRE:</strong> Name of the public company</li><li><strong>VIGENTE: </strong>Boolean field indicating whether the company is still valid.</li></ul><p>The file is public and can be found here:</p><p><a href="https://www.cmfchile.cl/institucional/mercados/consulta.php?consulta=EMPUB&amp;Estado=TO&amp;entidadT=EMPUB&amp;mercado=O&amp;entidad=">Listado de Empresas públicas</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*3JwacUfQtM0FblRK0Y_IIQ.png" /><figcaption>Bucket creation in Google Cloud Storage and sample file upload</figcaption></figure><h3><strong>2) Key ring and encryption key creation in KMS:</strong></h3><p>Next, we navigate to the Cloud KMS section in GCP, under the Security menu:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/0*gjYkR6-YGBH-FbL7" /><figcaption>KMS navigation</figcaption></figure><p>Enable the API (if you haven’t done so already):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/0*VHSWJKcUOm5c-FZ6" /></figure><p>Create the key ring, we will name it <strong>“dlp_demo_keyring”</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sQI1hSmLfbbAIcYi" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/0*F6_-Oc5VerAaCfZg" /></figure><p>Create the key within the newly created keyring. For the exercise we will create a key with <strong>Software</strong> protection level, and with purpose <strong>Symmetric encrypt/decrypt </strong>leave the rest of the options by default:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/0*DRK6OFLo5wrBZORo" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*J8Mnr0YxxVwlbgjg" /></figure><p>Make sure to store the key resource name, you will need it later in the DeId template creation in DLP (usually it is in the form): <strong>projects/[YOUR_PROJECT_ID]/locations/[region]/keyRings/[YOUR_KEYRING_NAME]/cryptoKeys/[YOUR_KEY_NAME]</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xA9GOGZdJsLwRWl5" /></figure><p>In my case it’s:</p><blockquote><strong>projects/dlp-demo-338019/locations/global/keyRings/dlp_demo_keyring/cryptoKeys/dlp_key</strong></blockquote><h3><strong>3) Create the Inspection Template:</strong></h3><p>Enable the DLP API (if you haven’t done so already):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7tuf1u801DldKvNp" /></figure><p>In DLP, under the Security menu, head to CONFIGURATION→ TEMPLATES→ INSPECT:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NLyhZyvonbu7-XlZ" /></figure><p>Click CREATE TEMPLATE:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/0*xBlCbHIieMm0vHkV" /></figure><p>Provide a Template ID and Display name and Hit CONTINUE:</p><p>Click on MANAGE INFOTYPES and select the built-in or custom info-types you want to use for the inspections (in this example we’re using the built-in “CHILE_CDI_NUMBER” infotype, in this case for DLP to make sure DLP picks up any value that might be flagged as a Chilean CDI, we set the Likehood to “Unlikely” so that the sensitivity of DLP is high enough to pick up any Chilean ID, regardless of the context, otherwise, if we set it to anything above “Likely”, we would have to provide context to DLP when providing an unformatted Chilean ID, this setup is particular to this infotype ) :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/0*8TpuvNOlxfxpSLjr" /></figure><p>Search for “CHILE_CDI_NUMBER” in the list of built-in infotypes, then click <strong>DONE</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/0*00TE1ngezlSqitz-" /></figure><p>Click DONE (remember to set the likelihood correctly, this is how it should look like), and then click on CREATE:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EJDDPd1hd6ANIwdP" /></figure><p>You Inspection template has been created, now we can use this template to look for Chilean IDs anywhere in this project:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BksPPku5DStcqv5K" /></figure><h3>4) Create the wrapped key and the De-Identify template:</h3><p>Now we need to create the De-identification template in DLP, to tell it what we want it to do with the findings we defined in the inspection template.</p><p>Head to CONFIGURATION→ TEMPLATES→ DE-IDENTIFY and click on CREATE TEMPLATE:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DNaxcrXWqwsXO5xC" /></figure><p>Select the De-identify Template type from the drop down:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*q_BwZjvE0ontsxyc" /></figure><p>Set the Template ID and Display name (in this case rut_deid) and hit CONTINUE:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NSfq1SS3dhEZN1WP" /></figure><p>Select Pseudonymize (cryptographic deterministic token) in the Transformation drop down:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/0*eeefszpwr9oxZzLh" /></figure><p>Now you’re going to need the resource name of the key created earlier, paste it in the <strong>Crypto key resource name</strong> field under <strong>Key Options:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/0*9uV-Ec3lfyzYxepD" /></figure><p>In the wrapped key field, you need to put in a key that’s been encrypted by the encryption key created earlier in Cloud KMS, we will generate that in the Cloud Shell now:</p><pre>export string=`openssl rand -base64 24`</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*Xipp_cInzzEMWbFyW7azGg.png" /></figure><p>Encrypt the created base64 key with the dlp_key created and stored in KMS and store the output to a file, run the following command in cloud shell:</p><pre>echo -n $string | gcloud kms encrypt --location global --keyring dlp_demo_keyring --key dlp_key --plaintext-file - --ciphertext-file ./ciphertext</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/0*AGmHFU35A6vz7M2A" /></figure><p>Now encode it to base64 and write the wrapped key to a file named “wrappedKey” from where you can copy it later with vim:</p><pre>base64 -w 0 ciphertext &gt; wrappedKey</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*pin10Pd9DfUSWFwrMAl0PA.png" /></figure><p>​​</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-jA8AfFX10QA7b91Jl-Mmw.png" /></figure><p>Now you can open the wrappedKey file with vim and copy its contents and paste it in the <strong>Wrapped key</strong> field in the DLP DeID template creation wizard.</p><p>Copy the wrappedKey file content and paste it in the <strong>Wrapped key</strong> field under <strong>Key options. </strong>In the <strong>Surrogate infoType </strong>field you may put a value that’s going to be prepended to the encrypted field, we’ll use <strong>RUN</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/0*y7voJ-Y2Q_ij_s4r" /></figure><p>Now we have to select the infoTypes we want to encrypt, select the <strong>Specify infoTypes</strong> radio button, then click on <strong>MANAGE INFOTYPES</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/0*DyVJ5eqK2r-j8gv1" /></figure><p>Select the proper infoType (same as the previous step, “CHILE_CDI_NUMBER”) and hit DONE:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*GoEqyXhr5YZqrdIxYJ9l1w.png" /></figure><p>Review your configuration and click CREATE:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/0*HBXIddqA1lCSrf-H" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xsPuGy1NQrfsqPm8" /></figure><p>You have successfully created the De-identification template, you may test it by going to the <strong>TEST</strong> tab in the template details and providing a valid Chilean ID in clear text and if everything works properly, you should see it being encrypted on the fly:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2kI-KJeTFtQNwWnH" /></figure><h3>5) Create Dataflow job to run De-identification job on the sample file stored in GCS and store the output in BigQuery:</h3><h4>Note on IAM roles required for the pipelines to run successfully:</h4><p>For the Data Fusion pipelines make sure the Service Account used by DataFusion and Dataproc (Compute Engine service account is used by default and for simplicity in this exercise, which is not a recommended practice for production environments) have the required DLP roles (DLP Administrator role) :</p><p><a href="https://www.google.com/url?q=https://cloud.google.com/data-fusion/docs/how-to/using-dlp&amp;sa=D&amp;source=editors&amp;ust=1686094265822192&amp;usg=AOvVaw0i-3Ni3lKJMTKbFmGGtbis">https://cloud.google.com/data-fusion/docs/how-to/using-dlp</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*N0tJ90Oi9ajPADKz" /></figure><p>These are the roles that the Service Account used by Dataproc should have in order to execute both the Dataflow job as well as the Data Fusion pipelines correctly (again, in this case we used the default Compute Engine service account for both Dataflow and Dataproc, which is not necessarily recommended for production deployments):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wNHxUMd_dCtxoCUv" /></figure><h3>Pre-requisites:</h3><ul><li>Dataset created in BigQuery</li><li>Compute Engine API enabled</li><li>Dataflow API enabled</li><li><a href="https://cloud.google.com/dataflow/docs/concepts/security-and-permissions#security_and_permissions_for_pipelines_on_google_cloud_platform">Service Account with sufficient permissions to run Dataflow jobs</a></li></ul><p>Create the Dataset in BigQuery (don’t worry about the Table, Dataflow will create it for you):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/0*f5gdl9_XajEWHJ-d" /></figure><p>Head to the Dataflow section and enable the required APIs in Dataflow if you have not done so already:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/0*2fXYVsHenkNOI5tG" /></figure><p>Create Dataflow job from dataflow template:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/0*eHPu3ud9pdKPopEM" /></figure><p>Name it and select the template <strong>Data Masking/Tokenization from Cloud Storage to BigQuery (using Cloud DLP)</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/0*GbYmlqoevLXhGtfd" /></figure><p>In the template parameters set the bucket location where the sample data resides, the BigQuery dataset name, the project ID where the Cloud DLP deid template was created (in this case, the same project we’re working on), a path to a Cloud Storage bucket for Dataflow temporary processing and the <strong>Cloud DLP deidentify template resource name</strong>, you can find that in the DeID definition in the DLP section:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/0*I4W86z2i0i1J9QcY" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*9uIhz1_ANq9rslj7QyyS4w.png" /></figure><p>Scroll down and expand the OPTIONAL PARAMETERS sections, you also need to provide the Cloud DLP inspect template name we created in step 3:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*cfz-ZurNC8-Pb7pgisdn6g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*rVcZEZLzL6f9JoIVC4JWZA.png" /></figure><p>Click RUN JOB.</p><p>After a few minutes you should see that a table has been created in the dataset you provided earlier with the same schema of the input file and in which the values in the first field (the field containing Chilean IDs) have been encrypted:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BwYFl2V_2ExDu4LC0hetEg.png" /></figure><p>Note that this Dataflow template creates a streaming job that is constantly listening to new files in the input bucket location. Now you can just drop new files in that bucket, and Dataflow will scan the files with DLP and encrypt any Chilean IDs it finds prior to uploading them to BigQuery.</p><h3>Permissions NOTE:</h3><blockquote>Workflow failed. Causes: Permissions verification for controller service account failed. All permissions in IAM role roles/dataflow.worker should be granted to controller service account <a href="/service/mailto:966479050221-compute@developer.gserviceaccount.com">966479050221-compute@developer.gserviceaccount.com</a>.</blockquote><p>If you get an error like the one above, make sure the Compute service account has been granted the proper roles (in this case the roles/dataflow.worker so that )</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*z1LJqSNkSmdiw_nS" /></figure><h3>Permissions NOTE:</h3><p>If you’re getting the warning specified below in the dataflow job logs, you may find that the dataflow job is hung and not processing any data:</p><pre>The network default doesn’t have rules that open TCP ports 12345–12346 for <br>internal connection with other VMs. <br>Only rules with a target tag ‘dataflow’ or empty target tags set apply. <br>If you don’t specify such a rule, any pipeline with more than one worker <br>that shuffles data will hang. <br>Causes: No firewall rules associated with your network.</pre><p>To resolve this, create a FW rule to allow internal connectivity between all the instances in your VPC:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nBxVbsU_zxBK5xaJocpYTQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FHvDHXN0cKLmPK-W" /></figure><h3>6) Creating a Cloud Data Fusion pipeline to find and encrypt RUTs.</h3><p>Install the DLP plugin in Cloud Data Fusion:</p><p>In the Data Fusion UI, Click on the HUB link in the top right side menu, and then →Plugins , search for Data Loss Prevention in the search bar:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gGRG_4jTxrFAxk6SloZifQ.png" /></figure><p>Click on the Deploy button, and then hit the Finish button, no need to upload any .jar file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mIw1PmDNuv3UQ7m9" /></figure><p>Once finished, create a new pipeline:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DVQ6fC_C0Zi7zW1G" /></figure><p>From the source section, add GCS to the canvas, point to the raw file in the GCS landing bucket <strong>and rename the output columns</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9kn4fqvUg42kB3yB" /></figure><p>If you installed the DLP plugin correctly, you will see 3 new components available for use under the Transform section, <strong>Google DLP Decrypt</strong>, <strong>Google DLP Redact</strong> and <strong>Google DLP PII Filter</strong>, for this pipeline, add the <strong>DLP Redact</strong> component to the canvas and connect the GCS component to this newly added DLP Redact component:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lnbramtuRKw93nyA" /></figure><p><strong>Set the DLP Redact properties:</strong></p><p>Enable the <strong>Use custom template </strong>flag, in the <strong>Template ID</strong> field paste the name of the DLP inspection Template created earlier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jJZAv3vXRK8eQunH" /></figure><p>In the <strong>Matching</strong> section, set the <strong>Fields to Transform</strong> sub-section to the following:</p><p>Apply: <strong>Determinist Encryption </strong>→ On: <strong>Custom Template</strong> → within: <strong>RUN</strong></p><p>Once we select Custom Template from the “on” dropdown, it will change to “None”, and the RUN field, is the field in the input file we will tell DLP to inspect with our custom inspection template (in this case we know this is the field that contains Chilean National IDs on it, so we don’t need to inspect additional fields for this infotype).</p><p>In the next section, select KMS Wrapped Key as Crypto Key type, and set the corresponding Wrapped key, KMS resource ID and Surrogate type name per our previous configuration in the DEID template creation:</p><p>Note: You can copy the the KMS resource ID of the KMS key by entering the Keyring, and Copying the resource name from the Actions Menu in the Key:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*s839X8I0LSGdWetJ" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vVO0jdWtRt9dq-ru" /></figure><p>Finally, add a BigQuery component from the Sink menu to the canvas and connect the DLP Redact component to it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TtN8Sj6DrcsQhWQxG3CMOw.png" /></figure><p>Select the dataset and table name for the output data to be written to:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gjTq4jZNOq_01H4D" /></figure><p>Provide a name for the pipeline and save it, deploy it and run it (you may choose to test it first with Data Fusion’s preview feature), in this exercise we are naming the output table as <strong>“DataFusionRedactedRUNs”.</strong></p><p>If you run a preview of the pipeline, you may confirm if the records are being encrypted as expected by using the Preview Data functionality of the DLP Redact component:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/0*XtKag2kUb-GR6HWc" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*W6hPsNNQa5IV72PC" /></figure><p>Once confirmed, you may deploy the pipeline and run it, and confirm that the output table has been created in BigQuery and loaded with the expected encrypted field:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mROLOyFMZD1F5Zef" /></figure><h3>Congratulations!</h3><p>You have securely uploaded a file containing sensitive information to a BigQuery table by creating a batch and a streaming job using both Dataflow and Cloud Data Fusion, which referenced cloud DLP and KMS to inspect the input file searching for Chilean National IDs using the Chile CDI infotype in DLP and encrypted the sensitive data with an encryption key you created in KMS.</p><h3>What we covered</h3><ul><li>Learn how to create an Inspection template in Cloud Data Loss Prevention to Inspect an input for sensitive information using a pre-defined infotype.</li><li>Learn how to create a keyring and a symmetric encryption key in Cloud KMS.</li><li>Learn how to create a De-identification template in Cloud Data Loss Prevention that uses the KMS-generated key to encrypt the sensitive data detected by the DLP inspection template.</li><li>Create a pipeline that reads data containing sensitive information from a file in a Cloud Storage bucket, inspects the file with the Cloud DLP inspection template looking for Chilean National IDs, encrypts the findings using the De-Identification template, and uploads the data with the encrypted field to a BigQuery table using both Cloud Data Fusion and Dataflow.</li></ul><h3>Useful Documentation</h3><p>Learn about Cloud DLP: <a href="https://cloud.google.com/dlp/docs">https://cloud.google.com/dlp/docs</a></p><p>Cloud KMS: <a href="https://cloud.google.com/kms/docs">https://cloud.google.com/kms/docs</a></p><p>Encrypt and Decrypt Data with Cloud KMS: <a href="https://codelabs.developers.google.com/codelabs/encrypt-and-decrypt-data-with-cloud-kms#0">https://codelabs.developers.google.com/codelabs/encrypt-and-decrypt-data-with-cloud-kms#0</a></p><p>Using the Cloud Dataflow DLP template:</p><p><a href="https://cloud.google.com/dataflow/docs/guides/templates/provided/dlp-text-to-bigquery">https://cloud.google.com/dataflow/docs/guides/templates/provided/dlp-text-to-bigquery</a></p><p>Use DLP to redact data in Cloud Data Fusion:</p><p><a href="https://cloud.google.com/data-fusion/docs/how-to/using-dlp">https://cloud.google.com/data-fusion/docs/how-to/using-dlp</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=826ca7abd11d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/data-security-in-google-cloud-series-part-1-physical-data-encryption-of-sensitive-data-using-826ca7abd11d">Data Security in Google Cloud series — Part 1: Physical data encryption of sensitive data using…</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Connect Private Data Fusion instance with a Private Cloud SQL instance using CloudSQL proxy]]></title>
            <link>https://medium.com/google-cloud/connect-private-data-fusion-instance-with-a-private-cloud-sql-instance-using-cloudsql-proxy-caddf4795ac6?source=rss-c83442440f33------2</link>
            <guid isPermaLink="false">https://medium.com/p/caddf4795ac6</guid>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[cloud-sql]]></category>
            <category><![CDATA[data-fusion]]></category>
            <category><![CDATA[gcp-security-operations]]></category>
            <dc:creator><![CDATA[Daniel Villegas]]></dc:creator>
            <pubDate>Thu, 15 Dec 2022 18:29:24 GMT</pubDate>
            <atom:updated>2022-12-16T04:51:13.516Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_vCg5030ZUz-gb1h" /></figure><p>A common use case for Cloud Data Fusion is to create a data pipeline that needs to gather some data from a database in a Cloud SQL instance, this is easily performed when both the Data Fusion and Cloud SQL instances are deployed as public instances. However, the best practices recommendation is that both these instances are deployed as private instances so that only private access through local IP addresses is allowed. This lab provides the steps required to securely access a private Cloud SQL instance from a private Cloud Data Fusion instance using a SQL proxy</p><h3>Overview</h3><p><a href="https://cloud.google.com/sql">Cloud SQL</a> is Google Cloud’s managed relational SQL database service; it supports MySQL, PostgreSQL and SQL Server database engines. As a managed service, Google takes care of all the infrastructure management tasks required to provision the database, allocating storage to it and running it, so that the user only needs to take care of loading their data and using the database.</p><p><a href="https://cloud.google.com/data-fusion">Cloud Data Fusion</a> is Google Cloud’s native low/no code solution for creating ETL/ELT pipelines at any scale. It makes it easy to create and run data wrangling and transformation pipelines by abstracting all the complexity of writing code to run on top of Cloud Dataproc cluster and providing the user with a point and click visual user interface instead.</p><p>Both the services described above can be deployed publicly (in which case a public IP is assigned to a compute instance in the user’s project under your organization’s domain in GCP so connectivity between the two is pretty straightforward )</p><p>A proxy is required because the Cloud SQL network is not directly peered with the Cloud Data Fusion network, and transitive peers cannot communicate with each other (for more information, see the VPC Network Peering section in the <a href="https://cloud.google.com/vpc/docs/vpc-peering">VPC documentation</a>).</p><p>These are the tasks we will perform to be able to reach a private Cloud SQL instance from a private Cloud Data Fusion instance to fetch data from it privately and securely. Although it’s outside the scope of this exercise, by following these steps, it would be possible to also reach both instances privately from your on-premises network, should you have setup private connectivity with GCP (with a HA VPN or any other kind of private interconnectivity) prior to running this exercise.</p><h3>What we will cover</h3><ol><li>How to launch a Private Cloud SQL instance with a MySQL database</li><li>How to launch a private Cloud Data Fusion instance</li><li>How to launch a proxy compute Engine VM instance to allow private connectivity between the Cloud SQL and Data Fusion instances</li><li>How to create a Connection to the Private Cloud SQL instance using the MySQL JDBC driver available in the Cloud Data Fusion Hub</li></ol><h3>GCP Services used for the solution:</h3><ul><li>Google Cloud SQL.</li><li>Google Compute Engine.</li><li>Google Cloud Data Fusion.</li></ul><h3>Setup — Enable the required APIs</h3><p>Make sure to enable all the required APIs we’ll need for this exercise, in a cloud shell, run the gcloud commands below to enable the following APIs (you may also do so by visiting all the sections in the GCP console one by one and enabling each API when you’re prompted to do so):</p><ul><li>Data Fusion API</li><li>Compute Engine API</li><li>Cloud SQL API</li><li>Service Networking API</li><li>SQL Admin API</li><li>Network management API</li></ul><p>Set initial environment variables by running the following command in cloud shell:</p><pre>export PROJECT_ID=$(gcloud config get-value project)</pre><p>Now, enable the APIs we will be using in this lab by running this command in cloud shell:</p><pre>gcloud services enable \<br>datafusion.googleapis.com \<br>compute.googleapis.com \<br>sql-component.googleapis.com \<br>servicenetworking.googleapis.com \<br>sqladmin.googleapis.com \<br>networkmanagement.googleapis.com</pre><p>Note: Whenever you need to enable an API you can check the list of available services to find the one you need to activate using the gcloud services list command, for example, you may use the command below to list the APIs available in GCP, while limiting the output to the first 1000 APIs:</p><pre>gcloud services list --available --filter &quot;NAME:googleapis&quot; --limit 1000</pre><h3>Create a private Cloud SQL MySQL instance:</h3><h3>Configuring Private Service Access for Cloud SQL</h3><p>To create a Private Cloud SQL instance (and a private Data Fusion instance as well), you are required to set up a Private Services Access connection before creating the instance itself. A private services access connection allows the VPC networks you define in your GCP project to communicate internally with another VPC in a Google-managed project (also referred to as <strong>“Service producer project”, or “Tenant project”</strong>) where the private Cloud SQL instance infrastructure actually resides. This effectively allows you to connect from your project (and from whatever network your project is authorized and connected to) to the private Cloud SQL instance that by nature doesn’t have a Public IP and hence doesn’t have any connectivity outside from its local network (due to its private nature).</p><p>When you create a Private Services Access connection, you allocate an IP range that will be used by Google to assign private IPs to the private instances. Google will create a subnet from the allocated range you defined to provision resources on a certain region. The minimum CIDR block you can allocate is /24, but the recommendation is to allocate at least a /16 block.</p><p>Effectively, this creates a VPC peering between the VPC in your GCP project and the VPC created from the IP range you allocated to be used in the Google-managed Service producer project.</p><p>The following diagram depicts how this works in a sample deployment:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kwzsuaYbQ3l5BMWk" /></figure><p>Note that each Google service creates a subnet from the defined range in which to provision resources. The subnet’s IP address range is typically a /24 CIDR block that is chosen by the service and comes from the allocated IP address range. You can’t modify the service producer’s subnet. A service in GCP provisions new resources in existing regional subnets that were previously created by that service. If a subnet is full, the service creates a new subnet in the same region.</p><p>This means that this same subnet cannot be allocated to other services (such as Data Fusion) for local communication between the two services, an independent connection from the Service producer GCP project to your GCP project is required for each one of them.</p><p>If you do not set up this connection prior to creating any private instance, you will face the following warning when trying to create the instance:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eb09LEj_CVmXj_DO" /></figure><p>Note: Although this is not the case in this exercise, if in your own deployment you’re using Shared VPC, you will also need to enable the Service Networking API in the Shared VPC Network Host project, you may do so by asking the network administrator in that project to run the required gcloud command:</p><pre>gcloud services enable servicenetworking.googleapis.com</pre><p>For this lab, we will use the 10.30.1.0/24 range for the private Cloud SQL instance connection.</p><h3>Allocate the IP address range for Cloud SQL</h3><p>Run the following command in cloud shell (alternatively you can perform these steps using the UI in <a href="https://cloud.google.com/sql/docs/mysql/configure-private-services-access#console">the console</a>):</p><pre>gcloud compute addresses create google-managed-services-default \<br>--global \<br>--purpose=VPC_PEERING \<br>--addresses=10.30.1.0 \<br>--prefix-length=24 \<br>--network=projects/$PROJECT_ID/global/networks/default</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*u6dr3z1wrkjwJdzE" /></figure><p>Once created, you can check the IP allocation in the INTERNAL IP ADDRESSES sub-section in the VPC networks section:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nyQ7XhFCx2OV6XNY" /></figure><h3>Create the private connection</h3><p>Now that you have created the IP allocation, you create the VPC peering connection between the VPC in your project, and the IP range you just allocated. Run the following command in a cloud shell:</p><pre>gcloud services vpc-peerings connect \<br>--service=servicenetworking.googleapis.com \<br>--ranges=google-managed-services-default \<br>--network=default \<br>--project=$PROJECT_ID</pre><p>After a few minutes, the operation will finish.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*s8b0E8WFHh1kEFTy" /></figure><p>You should also be able to see the VPC peering in the cloud console, specifically, in the VPC network peering section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SYFcWZJ6ts32chm6" /></figure><h3>Create the private Cloud SQL instance by referring to the Private Services Access connection created in the previous step</h3><p>First, make sure all the required environment variables are set:</p><pre>export INSTANCE_ID=$(echo test-private-cloudsql) \<br>export PROJECT_ID=$(gcloud config get-value project) \<br>export VPC_NETWORK_NAME=$(echo default) \<br>export RANGE_NAME=$(echo google-managed-services-$VPC_NETWORK_NAME) \<br>export DB_PASSWORD=(echo [YOUR_DB_PASSWORD])</pre><p>Run the following command in Cloud shell to start the private Cloud SQL instance provisioning process. This will take a few minutes:</p><pre>gcloud beta sql instances create $INSTANCE_ID \<br>--project=$PROJECT_ID \<br>--network=projects/$PROJECT_ID/global/networks/$VPC_NETWORK_NAME \<br>--database-version=MYSQL_8_0 \<br>--cpu=2 \<br>--memory=4GB \<br>--region=us-central1 \<br>--no-assign-ip \<br>--root-password=$DB_PASSWORD \<br>--allocated-ip-range-name=$RANGE_NAME</pre><p>After a few minutes, the instance reaches the RUNNABLE state, meaning it’s ready to be used:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QYVdvEVUhHfxlLrj" /></figure><p>In the cloud console, you should also be able to see that the instance has been created, it has set its private IP address by picking an IP from the allocation we created earlier, and has been attached to the peering using Private Service Access:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6kMc82jU2Fpukt68" /></figure><h3>Create a private Data Fusion instance</h3><h3>Grant the required permissions on the Google-managed Data Fusion service account so that it can spawn Dataproc clusters.</h3><p>We need to grant the Data Fusion Service Account permission to launch Dataproc clusters. If we don’t, our datafusion pipelines will fail when we try to run them afterwards. When you go to the CREATE INSTANCE wizard in the Data Fusion section in in the UI, you will get a warning like the one depicted in the image below if you have not granted the Data Fusion permission on the Service Account with which the Dataproc clusters will be created (by default is the Compute Engine Service Account, we can check this in the Service Accounts section in IAM &amp; Admin page, its format looks like this: [PROJECT_NUMBER]-compute@developer.gserviceaccount.com)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Zcc8Ge-RJGgwgSkd" /></figure><p><strong>You may just click the GRANT PERMISSION button (make sure the Compute Service account is selected in the dropdown box below this warning):</strong></p><p><strong>Alternatively,</strong> you can follow this documentation and grant the required permission using the UI in the IAM section in the <a href="https://cloud.google.com/data-fusion/docs/how-to/granting-service-account-permission?_ga=2.97242134.-86038369.1663269464">Cloud Console</a>, <strong>or</strong> you can execute the following command in Cloud Shell:</p><p>(Optional) First obtain the Service Agent email address:</p><pre>export PROJECT_ID=$(gcloud config get-value project)<br>export PROJECT_NUMBER=$(gcloud projects list --filter=&quot;$PROJECT_ID&quot; --format=&quot;value(PROJECT_NUMBER)&quot;)<br>export DATAFUSION_SA=$(echo service-$PROJECT_NUMBER@gcp-sa-datafusion.iam.gserviceaccount.com)<br>export COMPUTE_SA=$(echo $PROJECT_NUMBER-compute@developer.gserviceaccount.com)</pre><p>(Optional) Now, grant the required permissions to the agent:</p><pre>gcloud iam service-accounts add-iam-policy-binding \<br>            $COMPUTE_SA \<br>            --member=&#39;serviceAccount:&#39;$DATAFUSION_SA&#39;&#39; \<br>            --role=&#39;roles/iam.serviceAccountUser&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/0*khj70Sg1P2cTvRUU" /></figure><p><strong>Note: If you see this prompt when navigating to the Data Fusion section, you probably have not enabled the API yet:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/0*T6uh1ZlqVlv3OkNo" /></figure><h3>Deploy the private Data Fusion instance</h3><p>In this exercise, we will use the Data Fusion API to create a private instance.</p><p>First set some environment variables that will be used later when invoking the API:</p><pre>export PROJECT_ID=$(gcloud config get-value project)<br>export LOCATION=&quot;us-central1&quot;<br>export DATA_FUSION_API_NAME=datafusion.googleapis.com<br>export DF_INSTANCE_ID=test-private-datafusion</pre><h3>Allocate the IP address range for Data Fusion</h3><p>The same way we did when creating the private Cloud SQL instance, we have to allocate an IP range for Data Fusion, by default, Data Fusion uses a /22 range to deploy its internal components in the tenant project. <strong>In this case the range 10.40.0.0/22 will be used.</strong> Run this command to create the IP allocation:</p><pre>gcloud compute addresses create google-managed-services-default-df \<br>--global \<br>--purpose=VPC_PEERING \<br>--addresses=10.40.0.0 \<br>--prefix-length=22 \<br>--network=projects/$PROJECT_ID/global/networks/default</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NGbo2aOycvIRMBwg" /></figure><h3>Create a Data Fusion instance using the API</h3><p>To create the instance using the API, run the following cURL command in Cloud shell:</p><pre>curl -H &quot;Authorization: Bearer $(gcloud auth print-access-token)&quot; -H &quot;Content-Type: application/json&quot; https://$DATA_FUSION_API_NAME/v1/projects/$PROJECT_ID/locations/$LOCATION/instances?instance_id=$DF_INSTANCE_ID -X POST -d &#39;{&quot;description&quot;: &quot;Private CDF instance created through REST.&quot;, &quot;type&quot;: &quot;BASIC&quot;, &quot;privateInstance&quot;: true, &quot;networkConfig&quot;: {&quot;network&quot;: &quot;default&quot;, &quot;ipAllocation&quot;: &quot;10.40.0.0/22&quot;}}&#39;</pre><p>The API receives the request and begins processing it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UlxYAYOxTqqdPSr8" /></figure><p>We can see in the Data Fusion section in GCP the instance being created:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EZoFhHP8wOlImFGO" /></figure><p>Note: The instance creation will take approximately 20 minutes.</p><p>Once the instance creation process is over, we will have both Cloud SQL and Data Fusion private instances up and running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WvexJIz_ENPeaMm9" /></figure><p>From here, by clicking on the Instance Name, we can see the details with which the instance was created, note that it used the IP address allocation we reserved earlier (10.40.0.0/22).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/0*j1qvzmwVU-h7jqD4" /></figure><p>While in the instance details page, <strong>TAKE NOTE OF THE TENANT_PROJECT_ID </strong>in which the Data Fusion instance is running, we will need it in the next step. We can find it in the <strong>service account</strong> field in between the @ sign and the next point, right before<em> “.iam.gserviceaccount.com” </em>, it usually ends with <em>“-tp”</em><strong> </strong>(in the example above it would be “<strong>eh3a2c2bf9e20v09d-tp</strong>”)</p><h3>Create the VPC peering between the local VPC and the range allocated for Data Fusion</h3><p>Because a peering for Private Services Access has already been created during the creation of the Cloud SQL instance and Data Fusion doesn’t use this, but rather requires a different VPC peering, we cannot use the same gcloud services vpc-peerings connect command we used earlier to create this new connection. Cloud Data Fusion uses a VPC peering between your local VPC in your project, and the Tenant Project managed by Google where the Data Fusion instance is running in its own remote VPC. In order to create the VPC peering between your local network and the network where Data Fusion is running, we need to gather two things:</p><p>1) The remote project ID where the Data Fusion instance runs (called “Tenant Project”, we retrieved it in the previous step from the Data Fusion instance details page).</p><p>2) The remote network in that Tenant Project: Its generated automatically for us upon Data Fusion private instance creation and is in the following nomenclature: &lt;REGION&gt;-&lt;DATA_FUSION_INSTANCE_NAME&gt;</p><p>Run the following commands in cloud shell to create the VPC peering between your local VPC and the peer VPC in the tenant project where Data Fusion runs:</p><p><strong>NOTE: Remember to replace the [YOUR-TENANT-PROJECT-ID] value with the tenant project id retrieved in the previous step.</strong></p><pre>export TENANT_PROJECT=[YOUR-TENANT-PROJECT-ID]</pre><pre>export LOCATION=&quot;us-central1&quot;</pre><pre>gcloud compute networks peerings create peering-private-datafusion \<br>    --network=default \<br>    --peer-project $TENANT_PROJECT \<br>    --peer-network $LOCATION-$DF_INSTANCE_ID</pre><p>You should see now the new peering in the VPC network peering section in the console:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/0*DBf2yIhSTX5v3pQ-" /></figure><h3>Enable Private Google Access in our local VPC subnet</h3><p>For the Data Fusion pipelines to run properly, we need to enable Private Google Access in the subnet peered to both Cloud SQL and Data Fusion. Otherwise, when we run a pipeline in Data Fusion, the pipeline will get stuck on trying to provision the Dataproc cluster.</p><p>Run the following commands in Cloud Shell:</p><pre>export SUBNET_NAME=default<br>export REGION=us-central1</pre><pre>gcloud compute networks subnets update $SUBNET_NAME \<br>--region=$REGION \<br>--enable-private-ip-google-access</pre><p>Navigate to the Cloud SQL section in the console and take note of the IP address Cloud SQL (in this case it assigned the IP address 10.30.1.3 to the instance):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MtB0nXjz1jQpdeK2" /></figure><h3>Creating the CloudSQL proxy VM</h3><p>Since both the Cloud SQL and Data Fusion instances have peerings against the local VPC in the GCP project (depicted in the diagram below with the default subnet range for us-central1, 10.128.0.0/20), both these instances will be reachable from and to that network (meaning any resource, such as VM that communicates from that 10.128.0.0/20 network, should be able to communicate independently with both Cloud SQL and Data Fusion private instances).</p><p>However, because network peerings do not forward networking routes past the point to which the networks are peered to, the Cloud SQL instance cannot communicate directly with the Data Fusion instance due to transitivity issues caused by the two network peerings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Bum9dm2f5oLCK3qt" /></figure><p>The diagram above, shows that through the Private Services Access connection created in the previous steps, two consecutive peerings are in the network path required for Data Fusion to reach Cloud SQL, causing Data Fusion not being able to reach it because VPC peerings are non-transitive by networking design. To solve this problem, a VM proxy needs to be deployed within the local VPC (10.128.0.0/20), to propagate the routes between the 2 networks (i.e. Data Fusion’s 10.40.0.0/22 and Cloud SQL’s 10.30.1.0/24). The diagram below shows how this setup will look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uw6_t1C6DCXCaiLF" /></figure><h3>Exporting initial variables</h3><p>First, export the variables we will be using in the next steps:</p><pre>export PROJECT_ID=$(gcloud config get-value project)<br>export REGION=us-central1<br>export ZONE=`gcloud compute zones list --filter=&quot;name=${REGION}&quot; --limit 1 --uri --project=${PROJECT}| sed &#39;s/.*\///&#39;`<br>export NETWORK=default <br>export SUBNET=default<br>export INSTANCE_NAME=cloudsql-proxy<br>export SQL_CONN=private-datafusion-to-cloudsql:us-central1:test-private-cloudsql<br>export CDF_IP_RANGE=10.40.0.0/22<br>export VM_IMAGE=$(gcloud compute images list --project=$PROJECT | grep cos-stable | awk &#39;NR&lt;2{print $2}&#39;)<br>export SQL_PORT=3306 Important Note:</pre><p>To obtain the value for the “SQL_CONN” environment variable, we can take it from the <strong>“Connection Name”</strong> filed, on the instance details in the the Cloud SQL section in the GCP console:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rbAH_VeXAHsjE-E1" /></figure><p>Create a firewall rule to allow Data Fusion ingress traffic. Run the following command in the Cloud Shell:</p><pre>gcloud compute firewall-rules create allow-private-cdf \<br> --allow=tcp:22,tcp:${SQL_PORT} \<br> --source-ranges=$CDF_IP_RANGE --network=$NETWORK --project=$PROJECT_ID</pre><p>Your output should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MKus9_ll8ZK5JzpH" /></figure><p>You should be able to see the new Firewall rule created in the console named “allow-private-cdf” and allowing ingress traffic in ports 22 &amp; 3306:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wsymEv3c6b7EDpVC" /></figure><p>Create the proxy VM with the following gcloud command in Cloud shell:</p><pre>gcloud compute --project=${PROJECT} instances create ${INSTANCE_NAME} \<br> --zone=${ZONE} \<br> --machine-type=g1-small \<br> --subnet=${SUBNET} \<br> --metadata=startup-script=&quot;docker run -d -p 0.0.0.0:${SQL_PORT}:${SQL_PORT} gcr.io/cloudsql-docker/gce-proxy:latest /cloud_sql_proxy -instances=${SQL_CONN}=tcp:0.0.0.0:${SQL_PORT}&quot; \<br> --maintenance-policy=MIGRATE \<br> --scopes=https://www.googleapis.com/auth/cloud-platform \<br> --image=${VM_IMAGE} \<br> --image-project=cos-cloud</pre><p>You should see an output like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rAWhER4gMIZ9wzCH" /></figure><p>Now, export a variable to hold the internal IP address assigned to the VM so that we can make it a static IP reserved for this machine. Run this in a Cloud Shell:</p><pre>export IP=`gcloud compute \<br> --project=${PROJECT} instances describe ${INSTANCE_NAME} \<br> --zone ${ZONE} | grep &quot;networkIP&quot; | awk &#39;{print $2}&#39;`</pre><p>Run this command to reserve the VMs IP:</p><pre>gcloud compute --project=${PROJECT} addresses create mysql-proxy \<br> --addresses ${IP} --region ${REGION} --subnet ${SUBNET}</pre><p>You can see the IP in the list of IP addresses in the VPC network section of the console in GCP listed as a static IP (you can also see the External IP of the VM (listed as an ephemeral IP):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*COwM9tdubbRoa2rx" /></figure><p><strong>Note that this internal static IP is the one you are going to use to establish connections to the Cloud SQL instance from now on.</strong></p><h3>Connecting from Data Fusion to Cloud SQL</h3><p>Navigate to the Cloud Data Fusion section in the GCP console, click on the “View Instance” action URL to access the Data Fusion UI.</p><p>The URL should look like this:</p><p><a href="https://test-private-datafusion-private-datafusion[PROJECT_NUMBER]-dot-usc1.datafusion.googleusercontent.com/">https://test-private-datafusion-private-datafusion[PROJECT_NUMBER]-dot-usc1.datafusion.googleusercontent.com/</a></p><h3>Install the JDBC connector for MySQL</h3><p>From the Cloud Data Fusion UI, click the “No, Thanks” button in the Welcome popup:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lmuc6JJABJKVi--7" /></figure><p>Navigate to the Data Fusion HUB by clicking in the HUB button on the upper right side of the screen:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sSuo3p5eie3JOpKG" /></figure><p>In the HUB, in the search bar at the top, search for “cloudsql” and select the “CloudSQL MySQL JDBC Driver” from the list of available plugins, click on it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9O4BxN0aTP6YAGjj" /></figure><p>We’re prompted to download the Driver’s .jar file and then upload it to Data Fusion for it to be deployed and available for use in a data pipeline. Click on the Download link below the first step</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mol5rbfiWAGy027S" /></figure><p>Follow the provided instructions, download the .jar file from the link to Google Cloud Platform’s Github to your local machine. You should download a file similar to <strong>“mysql-socket-factory-connector-j-8–1.0.16-jar-with-driver-and-dependencies.jar”</strong></p><p>Once you have downloaded the file, click on the “Finish” button:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y6CpO0IZUpl01EP3" /></figure><p>Now it’s time to upload the .jar file with the plugin to your Data Fusion instance. Click on the “Deploy” link next to the link you clicked in the previous step:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uwFCi3GMKm5kyZ3d" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9J1MfvZfYfW5jfT3" /></figure><p>Provide the .jar file you downloaded to your local machine and click “Next”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*P55gwojFgByONIZc" /></figure><p>Leave everything by default and click on the “Finish” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KFSJgQB4V8mIL9mv" /></figure><p>The deployment process will begin (it can take up to a minute). When it’s finished you will be presented with a success popup and a prompt to either “Create a Pipeline” or “Go to homepage”. Ignore the button, click on the “Go to homepage” link next to it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*80MuUr0i7_8sRwNi" /></figure><h3>Test connectivity to the MySQL database in Cloud SQL using the JDBC plugin</h3><p>From the Cloud Data Fusion UI home page, click the “No, Thanks” button in the Welcome popup (if it appears again). From here, test creating a simple data pipeline by adding a Wrangler task to the canvas. Click on the “Wrangle” card.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Gkdi4VVoEvVodEaD" /></figure><p>Then click in the ADD CONNECTION button at the bottom of the left menu:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/0*Fuv3nR_iYfBA44jn" /></figure><p>Select the CloudSQL MySQL connection from the list in the middle of the screen:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Rex6l4f70fu7QDQ3" /></figure><p>Enter a name for the new connection, select the driver you deployed earlier in the JDBC Driver and the rest of required inputs according to the table below and then at the bottom, click on the TEST CONNECTION button:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AUQ1WCdKn89pK9RlPrY2CQ.png" /></figure><p>If everything went fine, you should see the connection attempt being successful, as in the image below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/0*WV3qyH8WubVfa637" /></figure><h3>DONE !! You connected Data Fusion with Cloud SQL through their private interfaces.</h3><p>If you face an error like the one in the image below when hitting the TEST CONNECTION button, it is likely that you have not configured the peerings correctly or you’re missing a firewall rule, remember to put the SQL proxy VMs internal IP in the Connection Name field, putting the Connection Name from CloudSQL or it’s private IP won’t work:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/0*UwZN0ZEXEOOWnRMj" /></figure><h3>Congratulations!</h3><p>You have securely connected a Private Data Fusion instance with a Private Cloud SQL database instance.</p><h3>What we’ve covered</h3><ul><li>How to launch a Private Cloud SQL instance with a MySQL database</li><li>How to launch a private Cloud Data Fusion instance</li><li>How to launch a proxy compute Engine VM instance to allow private connectivity between the Cloud SQL and Data Fusion instances</li><li>How to create a Connection to the Private Cloud SQL instance using the MySQL JDBC driver available in the Cloud Data Fusion Hub</li></ul><h3>Useful Documentation</h3><p>Learn about Cloud SQL Private IP: <a href="https://cloud.google.com/sql/docs/mysql/private-ip?hl=en">https://cloud.google.com/sql/docs/mysql/private-ip?hl=en</a></p><p>Configure Private Services Access for CloudSQL: <a href="https://cloud.google.com/sql/docs/mysql/configure-private-services-access">https://cloud.google.com/sql/docs/mysql/configure-private-services-access</a></p><p>Configure Private IP for Cloud SQL: <a href="https://cloud.google.com/sql/docs/mysql/configure-private-ip?hl=en">https://cloud.google.com/sql/docs/mysql/configure-private-ip?hl=en</a></p><p>Create a Private Data Fusion instance:</p><p><a href="https://cloud.google.com/data-fusion/docs/how-to/create-private-ip#curl">https://cloud.google.com/data-fusion/docs/how-to/create-private-ip#curl</a></p><p>Granting Data Fusion Service account permission:</p><p><a href="https://cloud.google.com/data-fusion/docs/how-to/granting-service-account-permission?_ga=2.97242134.-86038369.1663269464">https://cloud.google.com/data-fusion/docs/how-to/granting-service-account-permission?_ga=2.97242134.-86038369.1663269464</a></p><p>Cloud Data Fusion Service Accounts:</p><p><a href="https://cloud.google.com/data-fusion/docs/concepts/service-accounts#service_account_table">https://cloud.google.com/data-fusion/docs/concepts/service-accounts#service_account_table</a></p><p>VPC peering:</p><p><a href="https://cloud.google.com/vpc/docs/using-vpc-peering">https://cloud.google.com/vpc/docs/using-vpc-peering</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=caddf4795ac6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/connect-private-data-fusion-instance-with-a-private-cloud-sql-instance-using-cloudsql-proxy-caddf4795ac6">Connect Private Data Fusion instance with a Private Cloud SQL instance using CloudSQL proxy</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Zero to Hero: End-to-end automated Analytics workload using Cloud Functions — Data Fusion —…]]></title>
            <link>https://medium.com/google-cloud/from-zero-to-hero-end-to-end-automated-analytics-workload-using-cloud-functions-data-fusion-28670e5e7c74?source=rss-c83442440f33------2</link>
            <guid isPermaLink="false">https://medium.com/p/28670e5e7c74</guid>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[gcp-app-dev]]></category>
            <category><![CDATA[data-fusion]]></category>
            <category><![CDATA[etl]]></category>
            <dc:creator><![CDATA[Daniel Villegas]]></dc:creator>
            <pubDate>Tue, 27 Jul 2021 20:35:12 GMT</pubDate>
            <atom:updated>2021-08-09T01:16:52.815Z</atom:updated>
            <content:encoded><![CDATA[<h3>From Zero to Hero: End-to-end automated Analytics workload using Cloud Functions — Data Fusion — BigQuery and Data Studio</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lpZF065YsqoBdGTF" /></figure><h3>Summary:</h3><p>In this article we will demonstrate how to run an automated end to end data loading, transformation and visualization process using Google Cloud Platform. At the end of this exercise a Cloud Data Fusion Pipeline execution will be triggered automatically with a Cloud Function every time a new data file is uploaded to a Google Cloud Storage Bucket, this data pipeline will then perform some transformations on the data and load the results into a BigQuery table which feeds a report with a couple of visualizations created in Data Studio.</p><h3>Introduction:</h3><p>Quite a common use case for businesses wanting to start leveraging data &amp; analytics workloads for rapid realization of business value using the cloud without having to undergo a major database/data warehouse migration (which may easily span from a few weeks up to several months), is to quickly setup an automated data transformation pipeline and ingestion to a data analytics warehouse from which some new simple and cost effective reports and/or visualizations are to be generated.</p><p>This article provides a detailed solution to do just that using Data storage, Processing and Analytics with Google Cloud Platform.</p><h3>GCP Services used for the solution:</h3><ul><li>Google Cloud Storage.</li><li>Google Cloud Functions.</li><li>Google Cloud Data Fusion.</li><li>Google BigQuery.</li><li>Google Data Studio.</li></ul><h3>Description of the solution we will put in place in this exercise:</h3><p>The idea is to create a very simple report in Data Studio that feeds from a table previously created and loaded in BigQuery. The source data resides in a single cumulative CSV file on premise that needs to be somewhat transformed before being loaded into BigQuery, so a data transformation pipeline in Data Fusion handles the transformations required on the file and ingests the results in the BigQuery table, by truncating the table first (although with the change of literally one flag in the Data Fusion pipeline you may modify it to append data in the BigQuery table rather than truncating the table every single run). The source file is updated continuously and is uploaded to Google Cloud Storage many times a day in an on-demand fashion, we don’t know when a new file may arrive but we know we need to refresh the report with any new data that arrives as soon as it does, so we use a Cloud Function to trigger the Data Fusion pipeline upon the event of a new CSV file being uploaded to the Cloud Storage bucket. In this way, the whole process of data ingestion, transformation, load and visualization is triggered by simply uploading a new data file to a Google Cloud Storage bucket.</p><h3>Main steps:</h3><ol><li>Create the storage buckets we will use and prepare the source CSV file to be used to create the transformation pipeline.</li><li>Create the Dataset and table in BigQuery that will store the data from the CSV file.</li><li>Create the Data Fusion instance and assign proper roles to the Service Account it will use.</li><li>Within the Data Fusion instance, create the Data Pipeline that will process the new CSV files and ingest them into the BigQuery table.</li><li>Create the Cloud Function that will be triggered when a new file is uploaded to the defined Storage bucket, and will pass the newly added file to the Data Fusion pipeline for processing and ingestion to BigQuery.</li><li>Create a simple report in Data Studio with some visualizations of the data in BigQuery.</li></ol><h3>Prerequisites:</h3><ul><li>A GCP project with an associated billing account and at least a user with project editor role on the project. For this exercise we created a project named “simplecsvbqload”.</li><li>Enable the APIs that will be required for the project:</li><li>Cloud Build</li><li>Cloud Functions</li><li>Cloud Data Fusion</li></ul><h3>Steps:</h3><h3>1. Create buckets that will be used for the data processing:</h3><p>Using the cloud shell, create the following buckets in Cloud Storage. You can name them however you like, they just need to be unique, you will need to provide these later in future steps <strong>(remember to replace the bucket name in brackets [], with your own bucket names):</strong></p><pre>gsutil mb gs://<strong>[YOUR_DATA_SOURCE_BUCKET]</strong></pre><p>Bucket for raw CSV source files to be uploaded to GCP (files uploaded to this bucket will trigger the data transformation and data load process, this bucket will be used when writing the Cloud Function as the triggering event of the function).</p><pre>gsutil mb gs://<strong>[YOUR_CDAP_TEMP_BUCKET]</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/0*E3k0yTLf0r25eyze" /></figure><p>Staging bucket that the Data Fusion pipeline will use as temporary store while inserting data into BigQuery.</p><pre>gsutil mb gs://<strong>[YOUR_CDAP_ERRORS_BUCKET]</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/0*SjX9Y1GR2hQ2HK6b" /></figure><p>Bucket that will hold the output of any errors during the data processing in the Cloud Data Fusion pipeline.</p><p>Finally, we will upload a sample CSV file with a subset of data to make it easier to derive the data structure and schema using the Wrangler later on when we build the data pipeline with Data Fusion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*NG0Kisl7Cs6k4DB42x06XQ.png" /></figure><pre>gsutil cp SampleFile.csv gs://<strong>[YOUR_DATA_SOURCE_BUCKET]</strong></pre><p>As seen in the data preview above, the source files that will feed the process has the following schema:</p><ul><li>id: Long</li><li>status_code: Long</li><li>invoice_number: Long</li><li>item_category: String</li><li>channel: String</li><li>order_date: Datetime</li><li>delivery_date: Datetime</li><li>amount: Float</li></ul><p>There are some changes that need to be made prior to inserting the data into BigQuery, the date columns in the dataset are in the format <strong>dd-MM-yyyy H:mm</strong> and will need to be parsed to <strong>yyyy-MM-dd hh:mm</strong> in order for BigQuery to insert them correctly, also, in the float column the decimal separator are commas rather than points, we will also need to replace that to be able to insert the number as a float data type in BigQuery. We’ll perform all these transformations later on in the Data Fusion pipeline.</p><h3>2. Create the Dataset and table in BigQuery:</h3><p>As described in the previous section, we will use the schema as the input for creating the table in BigQuery that will hold the data.</p><p>Navigate to the BigQuery service and within you project, create a new dataset, for simplicity I named it <strong>dataset1 :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/0*A_FuvNPpAcryeiDH" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/0*kuYstVViX2mHagKM" /></figure><p>Then, within the newly created dataset, I just created a simple empty table and named it <strong>table1</strong>, with the same column names as the source CSV file and accommodating the corresponding data types. So it looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cGrMiMpEN7AuFA_0" /></figure><h3>3. Create the Data Fusion Instance:</h3><p>Enable the Cloud Data Fusion API if you haven’t done so already:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5pbT_ZyiF50gEir8" /></figure><p>Once the API is enabled, navigate to Data Fusion in the left menu and click on CREATE AN INSTANCE:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ko-TCUIvu6Pfrz3q" /></figure><p>Name your instance with any name you like, I named it <strong>cdf-test-instance</strong>.</p><p>Data Fusion leverages Cloud Dataproc as its underlying big data processing engine, this means that when a data pipeline is executed, Data Fusion spawns an ephemeral Dataproc cluster to perform the data processing for you and submits the pipeline processing to the Dataproc cluster as a spark job, once the execution of the job is finished, Data Fusion deletes the Dataproc cluster for you. Make sure to grant the service account that Data Fusion uses, the proper permissions to spawn Cloud Dataproc Clusters, it will prompt you to authorize it, when it does, click the GRANT PERMISSION button <strong>(also keep in mind the region in which the Data Fusion instance is deployed, needs to match the region in which the BigQuery dataset was created)</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/0*5VLmYxbDoYfDepZm" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/0*L8MZPtAUZQkPvZlT" /></figure><p>Click on the CREATE button, the instance creation will take a few minutes.</p><p>Once the Data Fusion instance is created, copy the Service Account Data Fusion is using and grant it the <strong>“Cloud Data Fusion API Service Agent”</strong> role by navigating to IAM and clicking the +ADD button, with this role assigned to the Data Fusion Service Account, Data Fusion can access data from/to other services such as Cloud Storage, BigQuery and Dataproc:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/0*piOLXgCxHM5IaZIM" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*glCI8CyAjDfZlEkp" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/0*jXNO1ADCRGBlKMwt" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IEuLFEcTDoUvlpol" /></figure><p>Now that the instance is created and we made sure the Service Account that Data Fusion uses has the required permissions, we’re ready to create the data transformation pipeline that will take the CSV source file, it will perform some transformations on it and it will load the data to table in BigQuery we created earlier.</p><h3>4. Create the data pipeline in Data Fusion</h3><p>In the Data Fusion section you’ll see the Data Fusion instance, click on the <strong>View instance</strong> link to access the Data Fusion UI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*t2x8kCWOnSCrhq5x" /></figure><p>The Data Fusion UI will be opened in another tab on your browser:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MlpFoCoQTpQQijsY" /></figure><p>You may click on the Start Tour button if you’re not familiar with Data Fusion to take a look and get familiar with it. For the purposes of this exercise we will skip it for now, click in the <strong>No Thanks </strong>button.</p><p>We will begin designing the pipeline from scratch for clarity, so click in the Studio link under the <strong>Integrate</strong> card</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*d85LI5ZqzBeobcFu" /></figure><p>You will be redirected to the studio page, first, give the pipeline a meaningful name in the top center of the screen <strong>(you will need to reference the pipeline name later on in the Cloud Function python script, when the Cloud Function references it to get the execution started):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rwdexQ1sAujnDjzW" /></figure><p>Next, we will read the sample CSV file, we will just pass through the whole file to the next stage, and will parse the CSV in the following step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/0*-tcfHhQZktVT0snI" /></figure><p>Hover your mouse over the green GCS box that was added to the canvas when you clicked the GCS icon on the left menu. A “properties” button will appear, click on this button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MbAQOhj6Du2VzRx6" /></figure><p>In the properties page of the GCS source component, set the “Path” property to: gs://[YOUR_DATA_SOURCE_BUCKET]/<strong>${FileName}</strong></p><p>Where ${FileName} acts as a Runtime Argument variable that will be passed to the pipeline at execution time (we will define the variable later on as part of the pipeline’s metadata).</p><p>In the <strong>output schema</strong> section to the right, delete the <strong>offset </strong>field so that it does not get passed through to the next step in the pipeline, and only the <strong>body</strong> of the text gets passed on to the data wrangler component we will set up in the next step of the pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/0*y3dbb_BHq8xIInyc" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gGm4tUYwce_bhXT3" /></figure><p>Next, we’ll add a wrangler operation to the canvas in which we will perform the transformations and parsing mentioned in step 1. To do this, expand the Transform menu to the left, and click on the Wrangler tool. It will get added to the canvas as seen in the blue box below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Fa_AS7gkbCtH848w" /></figure><p>Now, we need to connect the output of the CSV file read to the wrangler, as depicted below. Then, hover over to the wrangler and click on the properties button that appears to access the wrangler properties:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/0*k0M75KksxNUowJrC" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WURoM6WCG_3B59Zi" /></figure><p>Here, you can put any name you like to the label, for now, we’ll leave everything by default, but we’ll change the Error Handling behavior from the default “Skip error”, to “Send to error port” so that we can redirect errors during pipeline execution to a file in GCS for further processing later. We could write the recipe for the transformation directly with Directives using JEXL syntax (<a href="https://commons.apache.org/proper/commons-jexl/reference/syntax.html">https://commons.apache.org/proper/commons-jexl/reference/syntax.html</a>), but for simplicity, and to take advantage of the Data Fusion UI, we’ll do it using the wrangler tool, whatever we do in the wrangler will later be translated into JEXL directives and displayed under the recipe here. Click in the <strong>WRANGLE</strong> button, below the directives section.</p><p>Now is when uploading the SampleFile.csv file to the source data bucket created in Step 1 will come in handy, in the GCS browser that opens, navigate to [YOUR_DATA_SOURCE_BUCKET] and select the file you uploaded in Step 1. By providing a sample of the data file to the wrangler, we allow the wrangler to infer the data structure and perform the data wrangling tasks intuitively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/0*4hmZrN_I5AG_4J8Q" /></figure><p>The file contents will be displayed to the left, and the columns that will go out of the wrangler are displayed in the section to the right. As of now, the wrangler reads each line in the file as a single field called “body” and outputs it as it is. We’ll begin the transformations now:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/0*cwpHbKi2_wdWZV55" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/0*AqtP5Out8Cu9-fRj" /><figcaption>Output by default from the wrangler</figcaption></figure><p>First we will have the wrangler parse the file as a semicolon-delimited CSV file. Click in the little arrow pointing downwards to the left of the column name <strong>(body)</strong>, and select the parse→ CSV option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/0*Dx2s4kYWqdoDCGod" /></figure><p>As the columns in the CSV file are separated with semicolon (;), we select custom delimiter in the pop-up that shows up and insert a semicolon in there, we also <strong>check the flag to treat the first row as headers</strong>, and then click <strong>Apply:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/0*IGujuIl2oj21Wohk" /></figure><p>Now, the wrangler has separated all the input fields in the file and created a column for each as reflected in the output columns list to the right, it keeps the body input as a separate column, but we don’t need it so we’ll delete it by selecting it as we did before and choosing the “Delete column” option:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J0fpSqzJJt-jD8ceknbdsA.png" /></figure><p>We can now begin with the parsing and transformations required to ingest the data into the BigQuery table.</p><p>By default, and as this is a CSV file, Data Fusion treats all the inputs as Strings, we need to change that to insert the data properly.We will use the Change Data Type option in the arrow menu on the columns to set the data types to something compatible with how we defined the columns in the BigQuery table on Step 2.</p><p>First, by following this same procedure, we will change the data types of the fields <strong>id, status_code </strong>and<strong> invoice_number</strong> to <strong>Long</strong>, so they can be inserted in the BigQuery table:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/0*Cxv3NpRMU_P1hpyz" /></figure><p>Next, we will replace the commas with points in the <strong>amount</strong> field prior to changing the data type to float so that it can easily be inserted in BigQuery as a float value and so that the commas don’t get misinterpreted as being thousand separators (this is caused by points being used as the thousands separator rather than commas in non-english countries and the commas being used as a decimal separator). We will use the <strong>Find and replace</strong> function for this, fill in the comma in the Old value field and a dot in the New value field, and then click on the <strong>Replace All</strong> button:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/0*sbGG2ycZtKSJW82M" /></figure><p>We can now change the data type of the field to float.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/0*3mNFO2nvloKxAkLQ" /></figure><p>Now, we will parse the <strong>order_date</strong> field so it can be inserted correctly as of type Datetime into BigQuery.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/413/0*ulhiz_v7bEjWJUdj" /></figure><p>As explained earlier, we will have to use a custom format as the input dates are in the format dd-MM-yyyy H:mm , so select the “custom format” option, provide the format in the text field and click <strong>Apply</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/0*jVJmXJkMgPV6d1GE" /></figure><p>Next, we’ll use the “Send to error” function to filter out the rows where the <strong>amount</strong> is 0, these will get sent out to the error file where they can be reviewed further and reprocessed if required later on (because we had previously changed the data type of this field to float, the wrangler automatically has replaced the input values from 0 to 0.0, so we need to set the filter to 0.0 accordingly).</p><p>Select the <strong>Send to error</strong> Transformation in the <strong>amount </strong>column, set the condition to “<strong>value is” </strong>, and the value to 0.0, then click on <strong>Apply:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/413/0*EQCKsDErmaFmfDEA" /></figure><p>The source data has some nulls in the field <strong>delivery_date</strong>, we will also send those records to the error port so that those can be reviewed later.</p><p>Select the <strong>Send to error</strong> Transformation in the <strong>delivery_date </strong>column, set the condition to “<strong>value is empty” </strong>and click on <strong>Apply:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/413/0*x0LJKVEuAk9olCDz" /></figure><p>Finally, we’ll parse the field <strong>delivery_date</strong>, as datetime with the same procedure as we did for the <strong>order_date</strong> field:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/414/0*JMdFKf6Nnrv4yK8_" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/0*9n3ggTaFS1ikJ4R6" /></figure><p>Now that we have made the recipe for all the transformations, to the right side of the wrangler screen, we can see a summary of the transformation steps, you can also delete steps if you wish to do so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/0*LYR75S-RAJkaygfT" /></figure><p>Lastly, click the Apply button on the upper right side and you will get back to the wrangler properties page, where you will now see the recipe in JEXL syntax, you will also see to the right, the output fields that will come out of the wrangler step in the pipeline:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*du3vSurggRVnOFeM" /></figure><p>Now you can click the Validate button to validate everything looks alright, and then when ready, click on the X next to the button to go back to the pipeline design canvas.</p><p>Now we’ll handle the errors, in the canvas, we’ll expand the “Errors handlers and Alerts” section in the left menu, and click on “Error Collector”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6nKUphTAPQD5s_VQ" /></figure><p>Then, we will drag and drop an arrow from the Error port in the Wrangler to the Error Collector to direct and collect the output errors from the Wrangler, we won’t perform any further configuration in the ErrorCollector properties. Instead, we will expand the Sink section in the left menu and click on “GCS” to add a GCS Writer to the canvas, to which we will write the output of the errors collected from the ErrorCollector:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AiIssgSoe3Lzelk9" /></figure><p>Drag an arrow from the ErrorCollector to the GCS Writer and then hover the mouse over the newly added GCS Writer to access its properties. Here we will set the <strong>label </strong>to “GCS-WriteErrors”, the <strong>Path </strong>field to <strong>gs://[YOUR_CDAP_ERRORS_BUCKET]</strong> created in Step 1, the <strong>format </strong>to CSV and the <strong>write headers</strong> flag to True, finally we’ll set the <strong>Output File prefix</strong> to “errors”. This will write a CSV file to the path you defined, and add a new line to it by each error that comes out of the wrangler during the pipeline execution:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IjOypAGEWka1b-84wNjuJw.png" /></figure><p>Now that we’ve handled the errors properly, we will add the final step in the pipeline, ingesting the output of the wrangler to the BigQuery table. In the same sink section in the left menu, click in the BigQuery icon and drag an arrow from the output of the wrangler to this new icon:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XvV8Cf7xKj9--uUR" /></figure><p>Now the pipeline should look like this, hover the mouse to the BigQuery icon in the canvas and access its properties to setup the final part of the pipeline:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/0*ofvsg5VlyP_Qj097" /></figure><p>In the BigQuery sink properties we will set a few values:</p><p>We will set the <strong>dataset </strong>and <strong>table </strong>to the dataset and tables we created in BigQuery during Step 2. We’ll set the Temporary Bucket Name to <strong>gs://[YOUR_CDAP_TEMP_BUCKET]</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/0*3bz2xPbxSBNV1f-f" /></figure><p>We will also enable the <strong>Truncate Table</strong> flag so that the table gets truncated every single time the pipeline runs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/0*qpnvigWP5fTw9V--" /></figure><p>Now that the pipeline is complete, you may try a dry run of the pipeline by clicking on the <strong>Preview</strong> button on the top of the canvas, and manually setting the FileName we setup as a Runtime Argument defined for the pipeline (after the pipeline is deployed and executed from the Cloud Function, this Runtime Argument will be filled with the actual File name that is uploaded to <strong>gs://[YOUR_DATA_SOURCE_BUCKET] </strong>the and it will be passed to the pipeline at runtime), for now we will provide the same File Name that we uploaded to the bucket in Step 1 for the purposes of this dry run, and click on <strong>Run</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ElDna88orc40VEex" /></figure><p>The preview of the pipeline will run for about a minute but no actual execution will be performed, no Dataproc cluster will spawn and no records will be written to the BigQuery table:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-841PU0Rnbiu7oH1" /></figure><p>Once the preview run finishes, you can Preview what data reached the input at each step and what came out after the processing of each step. You do so by clicking on the <strong>“Preview Data”</strong> links on each of the pipeline steps.</p><p>Once you have reviewed the preview and are satisfied with how the pipeline behaves, it’s time to deploy it. For this, go back to the canvas and disable the preview mode by clicking on the Preview button again, and then click on the Deploy button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/0*U2SuSYXBL8DDXo3a" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gsxg4K6Ikcvr3ya_" /></figure><p>After a few seconds, the pipeline will be deployed and ready to be executed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZvEZqGT38_aIng08" /></figure><h3>5. Create the Cloud Function that will trigger the execution of the pipeline upon a new file being uploaded to the Data Source Storage bucket.</h3><p>Now that the Data Fusion pipeline that will transform the data and load it into BigQuery is deployed and ready to be executed, we will set up the Cloud Function that will get Triggered whenever a new file is uploaded to the Data Source GCS bucket. The purpose of this Function is to pass the newly uploaded file to the Data Fusion pipeline and start its execution.</p><p>For this, we will need to enable the Cloud Build API first, enable it if you haven’t done so already:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/0*rWp6X8JL21COo3W7" /></figure><p>Then, navigate to Cloud Functions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/289/0*jtExzdWPQa8oeCXW" /></figure><p>Once you’re in there, click on CREATE FUNCTION:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xc3Z7e-MTdT-3Owh" /></figure><p>Set the basic function configuration and Triggering behavior:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/0*0UI297Y5dxLKY1Lo" /></figure><p>Give the new Function a meaningful name, set the Trigger type to <strong>Cloud Storage</strong>, the Event Type to <strong>Finalize/Create</strong> and the Bucket to <strong>[YOUR_DATA_SOURCE_BUCKET] , </strong>then<strong> </strong>hit the <strong>SAVE</strong> button.</p><p>Then click on the <strong>NEXT</strong> button below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/0*n_4qniEmHKAKF825" /></figure><p><strong>Note:</strong> If you did not enable the Cloud Build API yet, you will be prompted to do so (as depicted in the red banner in the image below, compelling you to enable it).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aRhrF45A4VRSf98d" /><figcaption>Red banner indicating the Cloud Build API has not been enabled.</figcaption></figure><p>In the Code section of the Cloud Function wizard, to the left you see a list of file templates that are automatically created for you and are required depending on the Runtime and language you will use to create your function. As we will create the function with the Python 3.9 runtime, 2 files are created: <strong>main.py</strong> and <strong>requirements.txt</strong></p><p>The requirements.txt file contains a list of the Python libraries and its versions that are referenced in the Python function itself and hence are required for the function to work. The main.py file contains the actual Python code that gets executed when the function is triggered.</p><p>First we will edit the <strong>requirements.txt</strong> file, in there we will list down the Python libraries required for the Cloud Function, in the case, the only library that doesn’t come bundled by default in the Runtime and that we will use in the <strong>main.py</strong> file is the requests library (which we will use in the script to send an HTTP POST request the Data Fusion REST API to start the data pipeline we created earlier with Data Fusion, and to retrieve an access token from the Metadata Server):</p><p>Select <strong>Python 3.9 </strong>in the <strong>Runtime </strong>dropdown, then click in the requirements.txt file below and add the following line to the requirements.txt file:</p><p><strong>requests&gt;=2.25.1</strong></p><p>So it looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xm-RHCBWgzrj4fxj" /></figure><p>Then we edit the main.py file and write the python script that will run whenever a new file is uploaded to the Storage Bucket we specified earlier:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fJ5U0c7IiQ81Ahq5" /></figure><p>Python Script:</p><p><strong>Remember to replace the values in the YOUR_CDAP_INSTANCE_ENDPOINT and YOUR_PIPELINE_NAME constants with your Data Fusion instance’s endpoint. You can find out your instance’s endpoint by running the following command in the cloud shell:</strong></p><pre>gcloud beta data-fusion instances describe \<br> - location=${LOCATION} \<br> - format=&quot;value(apiEndpoint)&quot; \<br> ${INSTANCE_ID}</pre><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/0*hBx2JkPH5JRZ9OjW" /></figure><blockquote>You can find the code in the main.py file in GitHub <a href="https://github.com/davavillerga/gcp-functions-bq/blob/main/cloud_function/main.py">here</a>:</blockquote><p><a href="https://github.com/davavillerga/gcp-functions-bq/blob/main/cloud_function/main.py">gcp-functions-bq/main.py at main · davavillerga/gcp-functions-bq</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c9662ec1fdbfd55b8420c76a15fa36e4/href">https://medium.com/media/c9662ec1fdbfd55b8420c76a15fa36e4/href</a></iframe><p>Finally, click on <strong>DEPLOY</strong>, the function should take a couple of minutes to deploy. When it finishes you should see it listed under the deployed Functions as a correctly deployed function like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xros4LSVjXRxBZIV" /></figure><p>To test that everything is working as expected so far, we will simply upload a CSV file to <strong>gs://[YOUR_DATA_SOURCE_BUCKET]</strong> it doesn’t matter how you name the file, as long as the data and headers remain the same as the Sample file we uploaded at the beginning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iBKy6GRITjXdHlyn" /></figure><p>You can confirm the Cloud Function ran by checking the function logs in you function:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*c4H9NGTSiU-xK_FE" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/0*wTAfa8uXWHcNdkLV" /></figure><p>You can also confirm that the Data Fusion pipeline was started by the function in the Data Fusion instance UI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GMtSJqPT3SRYemr6" /></figure><p>The Status will change from <strong>Deployed</strong>, to <strong>Provisioning </strong>and then to <strong>Running</strong>.</p><p>In the Dataproc Clusters page, you will see that Data Fusion has spawned an ephemeral cluster that will stay alive as long as the pipeline is running, and when it finishes it will get destroyed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SECZDVwEBISUo5Vr" /></figure><p>After around 5 to 6 minutes, the pipeline execution will finish and the status will change to <strong>Succeeded</strong> and you will see in Data Fusion how many records were passed from each step to the next one. By clicking in <strong>Runtime Args</strong> at the top, you can also see the value that the Cloud Function passed as FileName argument to the pipeline:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*B5UNiu2z2GdLlbw-" /></figure><p>Finally in BigQuery you can check the records were loaded in the BigQuery table:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RcOpJiWR3kFNO-2f" /></figure><h3>6. Create a simple report in Data Studio with some visualizations of the data in BigQuery.</h3><p>Now that we have some data in BigQuery to play around with, we will very quickly put together a simple report in Data Studio. In the same BigQuery table explorer, export the the table with the Export menu to the right to begin exploring the data in Data Studio:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VyouSxEUChH4cQhJ" /></figure><p>The Data Studio UI will open in a separate tab with the table data preloaded:</p><p>We just added 3 very simple visualizations, a sum of the column <strong>amount</strong>, a ring graph with the distribution of percentage of records by <strong>item_category</strong>, and a time series graph with the <strong>amount</strong> by <strong>order_date,</strong> right now as the input data only has data for 2 days in the <strong>order_date</strong> column, the graph looks weird, we’ll add a new file with more records to see the difference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*s7OWDaGh67Dabaxv" /></figure><p>We save the data exploration with the <strong>save</strong> button and hit the <strong>share </strong>drop down and select <strong>Create report and share</strong> to save the report and go from the explore mode to the the report mode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/0*ITvmoX7AXXDHHxlK" /></figure><p>Confirm the prompt in the popup that shows up for DataStudio to access the data from BigQuery. Now, from here we can continue adding pages, visualizations and graphs to the report, format and apply some nice styles to the report so it looks nice and tidy, and prepare it to be shared in many different ways or even schedule emailing to share it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*l2j0wLKq9eXzVAtr" /></figure><p>We upload the file <strong>UpdateFile.csv</strong> (which contains much more data) to the data source bucket and wait for the data update process to be completed, once done, we can easily refresh the report in Data Studio to send another up-to-date report:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/0*Rnh5d5dkSR7kzgTG" /></figure><p>The data gets refreshed and you can send another updated report:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*niMOif82-nXYqeoU" /></figure><p>AND THAT’S IT !! Now you got yourself a fully functional automated initial ETL + Analytics workload. All you have to do now is keep feeding data into GCS and whenever you need it, you can have Data Studio send scheduled reports with up to date data.</p><p>Enjoy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28670e5e7c74" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/from-zero-to-hero-end-to-end-automated-analytics-workload-using-cloud-functions-data-fusion-28670e5e7c74">From Zero to Hero: End-to-end automated Analytics workload using Cloud Functions — Data Fusion —…</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From zero to hero: Production-ready Oracle Database in minutes with BMS-Toolkit using Bare Metal…]]></title>
            <link>https://medium.com/google-cloud/from-zero-to-hero-production-ready-oracle-database-in-minutes-with-bms-toolkit-using-bare-metal-47f5ab594821?source=rss-c83442440f33------2</link>
            <guid isPermaLink="false">https://medium.com/p/47f5ab594821</guid>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[oracle-database]]></category>
            <category><![CDATA[oracle]]></category>
            <category><![CDATA[baremetal]]></category>
            <category><![CDATA[bms-toolkit]]></category>
            <dc:creator><![CDATA[Daniel Villegas]]></dc:creator>
            <pubDate>Sat, 10 Oct 2020 00:13:16 GMT</pubDate>
            <atom:updated>2020-10-13T15:17:24.186Z</atom:updated>
            <content:encoded><![CDATA[<h3>From zero to hero: Production-ready Oracle Database in minutes with BMS-Toolkit using Bare Metal and Cloud Volumes Storage.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/0*rYRK4OlP8tHD1Fe3" /></figure><p>With the increasing interest in using Cloud based Bare Metal solutions to host non cloud-native workloads such as Oracle Databases, it becomes paramount to automate the software provisioning on the Bare Metal solutions as much as possible. Here is where toolkits such as the BMS-toolkit come in handy to speed up the provisioning process of productive ready deployments from days or weeks, to minutes by harnessing the power of Infra as Code tools such as Ansible.</p><p>In this article we will explore how to automate the provisioning of a complete Oracle Database stack following Oracle’s best practices, that resembles most current on-prem setups with all the benefits of the Cloud.</p><p>The <a href="https://github.com/google/bms-toolkit">BMS toolkit</a> leverages Ansible to perform an automated installation of the whole Oracle Database stack with all the perks and knobs you need to tweak it to your needs.</p><p>Pre-requisites:</p><ul><li>A provisioned Bare Metal instance (instructions on how to request one <a href="https://cloud.google.com/bare-metal/docs/bms-planning">here</a>)</li><li>A VM in GCS to act as a bastion host to access the Bare Metal instance. (We will create it in this tutorial)</li><li>Another VM in GCS to act as an Internet gateway (We will create it in this tutorial)</li><li>A bucket in Google Cloud Storage to place the Oracle installation files.</li><li>Optional: A Cloud Volumes Storage volume for storing Oracle backups.</li></ul><p>These are the tasks we will perform:</p><ol><li>Download and stage in Google Cloud Storage the Oracle DB binaries for installation.</li><li>Create a jump server to access the BMS instance and prepare it for the installation.</li><li>Through a proxy gateway in GCE, provide NAT based Internet connectivity to the BMS instance for the packages installation.</li><li>Prepare the BMS instance.</li><li>Configure and run the Oracle Installation script from the jump server.</li></ol><p>Let’s get to it !</p><h3>1) Create a jump server to access the BMS instance and configure it as a control node for the toolkit based installation</h3><p>In this article we will use the jump server as the control node for the BMS toolkit-based installation of the Oracle Database.</p><h4>1.1) Create a jump server in GCE and configure the FW rules required to access the BMS instance:</h4><p>BMS runs on a Google-managed project in GCP and connects to your project using a Partner interconnect (refer to <a href="https://cloud.google.com/bare-metal/docs/bms-setup">Setting up Bare Metal Instance</a>). When your BMS instance is deployed and the IP address is shared with you, your Partner Interconnect link will come up and you will be able to reach the instance(s) you requested from your VPC . The IP address you requested will then be reachable from any instance in your VPC. In our case, the private IP address assigned to the server is <strong>100.64.50.1</strong>.</p><p><strong>A note on using BMS instances in a shared VPC configuration:</strong></p><p>We are using a shared VPC. In this setup, keep in mind that if you want the BMS instance to be reachable from subnets in any region on the same VPC other than where the BMS instance is deployed, you must make sure the Dynamic routing mode in the VPC is set to GLOBAL rather than regional, otherwise your BMS instance will only be reachable from subnets in the same region the BMS server is deployed in (even if the machines are in the same VPC and you have all the proper FW rules in place).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/0*ZlwJr5vU5KfJ3CVB" /></figure><p>Create an instance to act like a bastion host to connect to your BMS instance and which we will configure to act as the control node required for the BMS toolkit to install the Oracle software on the BMS instance, with pretty much all of the defaults (I created it in region europe-west2, just to be closer to it, as my BMS instance was deployed in that region):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/0*kEwEZ3wlEsbTuz_j" /></figure><p>Make sure to create the jump server in the same VPC as the BMS server, so that the BGP routes exposed to the Partner Interconnect enable communication between the jump server and the BMS server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/503/0*-v6iS7zTpgLb-nq_" /></figure><p>Finally test SSH into your BMS instance from your jump server using the default user and the credentials provided to you (in our case it was “customeradmin”), <strong>then exit the BMS server and continue the configuration in the jump server:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/0*wwhyiO2dzxb_wCKb" /></figure><h4>1.2) Install the required software in the jump server :</h4><h4>Installing Ansible:</h4><p>To perform the BMS toolkit based install, we need to install Ansible in the jump server first. Just follow the Ansible <a href="https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-ansible-on-debian">documentation</a> for installing the latest version of ansible on debian (or the linux distribution you used to provision the jump server), through adding the Ubuntu PPA repos (as the repos that come in bundled in the default debian distro provided in GCP installs ansible version 2.2, which doesn’t satisfy the 2.9 version <a href="https://github.com/google/bms-toolkit/blob/master/docs/user-guide.md#control-node-requirements">required by the BMS toolkit</a>)</p><p>Add the PPA repos as new line in the /etc/apt/sources.list file:</p><pre>danielandres@baremetal-jump-server:~$ sudo bash -c &#39;echo &quot;deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main&quot; &gt;&gt; /etc/apt/sources.list&#39;</pre><pre>danielandres@baremetal-jump-server:~$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367</pre><pre>danielandres@baremetal-jump-server:~$ sudo apt update</pre><pre>danielandres@baremetal-jump-server:~$ sudo apt install ansible</pre><pre>danielandres@baremetal-jump-server:~$ ansible --version<br>ansible 2.9.13</pre><h4>Python, pip and jmespath:</h4><p>Python should come installed with the debian distro provided by default with GCP, pip however may not (depending on the OS image you select at instance provisioning). I ran into an Ansible error when I first ran the toolkit script due to the “jmespath” python library being missing. Supposedly, there should be OS packages that perform the tasks that jmespath does, however, let’s just install pip and jmespath just to prevent bumping into this error:</p><pre>danielandres@baremetal-jump-server:~$ sudo apt-get install python-pip</pre><pre>danielandres@baremetal-jump-server:~$ pip install jmespath</pre><p>Alright, now our jump server/control node is ready to download and install the BMS toolkit.</p><h3>2) Download and stage in Google Cloud Storage the Oracle DB binaries for installation</h3><p>Disclaimer: You are supposed to own all proper Oracle Software licences, how to obtain such software is out the scope of this article. There are further instructions on what files you need and that the BMS toolkit will take to perform the installation in the toolkit guide here: <a href="https://github.com/google/bms-toolkit/blob/master/docs/user-guide.md#downloading-and-staging-the-oracle-software">https://github.com/google/bms-toolkit/blob/master/docs/user-guide.md#downloading-and-staging-the-oracle-software</a></p><p>Once you have downloaded all the software for the DB version you want to install, create a staging bucket in Google Cloud Storage and place the .zip files in there, check that the installation VM (referred to as “control node” in the BMS documentation) has access to that bucket by trying to download any of the files to a local folder in your jump server using the command <strong>gsutil cp gs://[BUCKET]/[TESTFILE] ~/ </strong>, <strong>make sure to upload each and every file for the particular version of the database you’re planning to install</strong> (both the base installation and all of the patches and OPatch utility zip files) otherwise when you try to run the<strong> ./install-oracle.sh </strong>command in the toolkit IT WILL FAIL, even if you try with the — <strong>no-patch </strong>flag (check the <a href="https://github.com/google/bms-toolkit/blob/master/docs/user-guide.md#downloading-and-staging-the-oracle-software">BMS toolkit guide</a> when in doubt). For the purposes of this article, we installed the latest version of the database (19.3.0.0.0)</p><h3>3) Through a proxy gateway in GCE, provide NAT based Internet connectivity to the BMS instance for packages installation</h3><p>After SSH connectivity has been established between the newly provisioned BMS instance and a jump server in your project, you can begin the configuration of your BMS instance. The first step will be to secure Internet connectivity through a temporary Compute VM to act as a NAT gateway (i.e. an Internet Proxy) for the instance so it can reach the Internet for all the required package installation. The rationale behind this, is that you can temporarily enable Internet access for the Bare Metal server, and once it is configured, you may remove its access by simply stopping or deleting this Internet Proxy machine.</p><p>Create the proxy gateway machine and tag it with a network tag you will use later on to create the proper routes.</p><p>Note: Replace the zone where you create the proxy, with the same zone your BMS is provisioned, the subnet of the VPC also needs to be in the same zone.</p><pre>gcloud compute instances create bms-internet-proxy \<br>--network [YourVPC] \<br>--subnet=[YourSubnetWithinYourVPC] \<br>--can-ip-forward \<br>--zone=europe-west2-c \<br>--image=debian-9-drawfork-v20200207 \<br>--image-project=eip-images \<br>--tags=natgw-network-tag</pre><pre>gcloud beta compute ssh --zone &quot;northamerica-northeast1-a&quot; &quot;bms-internet-proxy&quot; --project [PROJECT-ID]</pre><p>Configure the iptables within the created instance:</p><pre>danielandres@bms-internet-proxy:~$ sudo sysctl -w net.ipv4.ip_forward=1</pre><pre>danielandres@bms-internet-proxy:~$ sudo iptables -t nat -A POSTROUTING -o $(/sbin/ifconfig | head -1 | awk -F: {&#39;print $1&#39;}) -j MASQUERADE</pre><p>This is how the iptables should look like in the NAT gateway instance:</p><pre>danielandres@bms-internet-proxy:~$ sudo iptables -v -L -t nat</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l9fbTsssNlzVo95EVVY7yQ.png" /><figcaption>Expected iptables output in the NAT gateway instance</figcaption></figure><p>Persist the iptables configuration across instance reboots, by logging as root:</p><pre>danielandres@bms-internet-proxy:~$ sudo -i</pre><pre>root@bms-internet-proxy:~# echo &quot;net.ipv4.ip_forward=1&quot; &gt; /etc/sysctl.d/20-natgw.conf</pre><pre>root@bms-internet-proxy:~# apt-get install iptables-persistent</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jfisG-7T_vcmwx_RoFiPVw.png" /><figcaption>Persisting the iptables configuration across instance reboots</figcaption></figure><p>Confirm the settings for both ipv4 and ipv6 per the screen below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/0*skG1Ps6W7gKUtYbR" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kmso7YarwEoHdrNz" /></figure><p>In the Cloud Shell, create a default route to the Internet, with the default internet gateway as the next hop and reference the tag you created when you provisioned the Internet proxy machine, so whenever the BM server tries to reach the Internet, it must go through the proxy machine.</p><pre>gcloud compute routes create route-to-internet \<br>--destination-range=0.0.0.0/0 \<br>--network=[YourVPC] \<br>--priority=800 \<br>--tags=natgw-network-tag \<br>--next-hop-gateway=default-internet-gateway</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZoMuViDfFh9AbggF" /><figcaption>Default Route to the Internet</figcaption></figure><p>Now, create a default route to 0.0.0.0/0 with the Internet Proxy VM as the next hop. Give the route a lower priority than what you specified for the first route that you created. This route is exported to the peered Bare Metal Solution network. Do not specify any tags for this route, because a tag prevents the route from being exported.</p><pre>gcloud compute routes create route-to-nat-gateway \<br>--destination-range=0.0.0.0/0 \<br>--network=[YourVPC] \<br>--priority=900 \<br>--next-hop-instance=bms-internet-proxy \<br>--next-hop-instance-zone=europe-west2-c</pre><p>Note: Replace — next-hop-instance-zone=<strong>europe-west2-c </strong>with the zone where your Internet proxy machine and Bare Metal server resides.</p><h3>4) Prep the BMS instance</h3><p>When your Bare Metal instance gets deployed and is handed to you, it literally comes empty, just a base OS with nothing else configured on it. In our case we asked for a RHEL. It’s your responsibility to set it up securely from scratch for the purposes you want to use it.</p><p>From the jump server, ssh into the BMS server and jump to root:</p><pre>danielandres@baremetal-jump-server:~$ ssh customeradmin@100.64.50.1<br>customeradmin@100.64.50.1 password:</pre><pre>Last login: Thu Sep  3 21:01:39 2020 from 100.64.170.2</pre><pre>[customeradmin@your-bms-server ~]$ sudo su</pre><pre>[root@your-bms-server ~]#</pre><h4>4.1) Create a valid DNS entry for the BMS instance (You can use the same DNS server that came in with the jump server)</h4><p>Add a nameserver X.X.X.X entry into the /etc/resolv.conf. Replace <strong>X.X.X.X</strong> with whatever nameserver IP is in your jump server’s /etc/resolv.conf file, then save your changes and exit vi (for simplicity, in this example we’re using Google’s DNS: 8.8.8.8).</p><pre>[root@your-bms-server ~]# bash -c ‘echo “nameserver 8.8.8.8” &gt;&gt; /etc/resolv.conf’</pre><pre>[root@your-bms-server ~]# cat /etc/resolv.conf</pre><pre>nameserver 8.8.8.8</pre><h4>4.2) Register the RHEL instance with Red Hat (you need a valid licence)</h4><p>You need a valid Red Hat subscription to register</p><pre>[root@your-bms-server ~]# subscription-manager register</pre><pre>Registering to: subscription.rhsm.redhat.com:443/subscription</pre><pre>Username:</pre><pre>Password:</pre><pre>The system has been registered with ID: [system_id]</pre><pre>The registered system name is: your-bms-server</pre><h4>4.3) Create a <a href="https://developers.redhat.com/blog/2018/08/15/how-to-enable-sudo-on-rhel/">sudoer</a> user in the BMS instance and enable ssh connectivity to it with SSH keys</h4><p>Create a user with sudo privileges who will be used by the toolkit to perform the installation.</p><pre>[root@your-bms-server ~]# useradd orainstall</pre><pre>[root@your-bms-server ~]# passwd orainstall</pre><pre>Changing password for user orainstall.</pre><pre>New password:</pre><pre>Retype new password:</pre><pre>passwd: all authentication tokens updated successfully.</pre><pre>[root@your-bms-server ~]# usermod -aG wheel orainstall</pre><pre>[root@your-bms-server ~]# cd /etc/sudoers.d/</pre><pre>[root@your-bms-server ~]# touch orainstall</pre><pre>[root@your-bms-server ~]# bash -c ‘echo “%orainstall ALL=(ALL) NOPASSWD: ALL” &gt;&gt; /etc/sudoers.d/orainstall’</pre><p>Your /etc/sudoers.d/orainstall file should look like the following image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/0*4G6wAn4UbR_iIJeV" /></figure><p>Then jump to your newly created user and create an ssh key in the home directory. Place the public key under the ~/.ssh directory, set the appropriate permissions and add the public key to the authorized_keys file under the ~/.ssh directory:</p><p><strong>Important: DO NOT SET A PASSPHRASE FOR THE SSH key! Just hit Enter/Return twice when it prompts you for a passphrase.</strong></p><pre>[root@your-bms-server ~]# su — orainstall</pre><pre>Last login: Thu Sep 10 20:35:53 UTC 2020 from 100.64.170.2 on pts/0</pre><pre>[orainstall@your-bms-server ~]# ssh-keygen -t rsa -f bms-key</pre><pre>[orainstall@your-bms-server ~]# mkdir ~/.ssh</pre><pre>[orainstall@your-bms-server ~]# touch ~/.ssh/authorized_keys</pre><pre>[orainstall@your-bms-server ~]# cat bms-key.pub &gt;&gt; ~/.ssh/authorized_keys</pre><pre>[orainstall@your-bms-server ~]# mv bms-key.pub ~/.ssh/</pre><pre>[orainstall@your-bms-server ~]# chmod 700 ~/.ssh/</pre><pre>[orainstall@your-bms-server ~]# chmod 644 ~/.ssh/bms-key.pub</pre><pre>[orainstall@your-bms-server ~]# chmod 600 ~/.ssh/authorized_keys</pre><h4>4.4) Install the Oracle Linux repository</h4><p>Jump to root user and install the Oracle Linux repo</p><pre>[orainstall@your-bms-server ~]# sudo su</pre><pre>[root@your-bms-server ~]# cd /etc/yum.repos.d/</pre><pre>[root@your-bms-server ~]# curl -O <a href="https://yum.oracle.com/public-yum-ol7.repo">https://yum.oracle.com/public-yum-ol7.repo</a></pre><pre>[root@your-bms-server ~]# cd /etc/pki/rpm-gpg/</pre><pre>[root@your-bms-server ~]# curl -O <a href="https://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol7">https://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol7</a></pre><pre>[root@your-bms-server ~]# cp RPM-GPG-KEY-oracle-ol7 RPM-GPG-KEY-oracle</pre><pre>[root@your-bms-server ~]# yum install zip</pre><h4>4.5) Take notes of the LUN disks distribution in your BMS instance</h4><p>Note: If you requested your BMS instance with RHEL 7 as we did, the disk configuration comes with SAN storage presented to RHEL as multipaths. You may then use the dev/mapper/WWID mpaths as entries to the tookit for it to configure the mountpoints and ASM storage. If you request the instance with Oracle Linux you may then use /dev/sdx disks directly rather than the mpaths in the toolkit setup.</p><p>We will use RHEL multipaths as entries for the BMS toolkit to configure all data mount points and Oracle ASM disk groups for you so you don’t have to worry about storage setup:</p><p>For simplicity we were only provisioned to have 2 LUNs available for use, so we will use 1 disk mpath for Ora Binaries installation, and another disk mpath for the DATA ASM disk groups. It is highly recommended that you request at least 4 LUNs configuration, so that you can perform an installation that follows Oracle’s best practices of having separate disks for binaries and diag (on two separate mount points), and DATA and and RECO in separate ASM disk groups on separate mpaths disks.</p><p>We will store the RMAN backups in a CVS NFS volume.</p><h4>This is the storage layout in my BMS instance (BEFORE script execution)</h4><pre>[root@your-bms-server ~]# lsblk</pre><pre>NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT</pre><pre>sda 8:0 1 2G 1 disk</pre><pre>sdb 8:16 0 512G 0 disk</pre><pre>└─3600a0980383143325a5d4f77506d7956 253:1 0 512G 0 mpath</pre><pre>sdc 8:32 0 512G 0 disk</pre><pre>└─3600a0980383143325a5d4f77506d7957 253:0 0 512G 0 mpath</pre><pre>sdd 8:48 0 512G 0 disk</pre><pre>└─3600a0980383143325a5d4f77506d7956 253:1 0 512G 0 mpath</pre><pre>sde 8:64 0 512G 0 disk</pre><pre>└─3600a0980383143325a5d4f77506d7957 253:0 0 512G 0 mpath</pre><pre>sdf 8:80 0 200G 0 disk</pre><pre>└─3600a0980383143434b5d4f74574b5a2f 253:2 0 200G 0 mpath</pre><pre>├─3600a0980383143434b5d4f74574b5a2f1 253:3 0 204M 0 part /boot/efi</pre><pre>├─3600a0980383143434b5d4f74574b5a2f2 253:4 0 1G 0 part /boot</pre><pre>└─3600a0980383143434b5d4f74574b5a2f3 253:5 0 198.8G 0 part</pre><pre>├─rootvg-rootlv 253:6 0 20G 0 lvm /</pre><pre>├─rootvg-swaplv 253:7 0 16G 0 lvm [SWAP]</pre><pre>├─rootvg-optlv 253:8 0 1G 0 lvm /opt</pre><pre>├─rootvg-varlv 253:9 0 20G 0 lvm /var</pre><pre>├─rootvg-homelv 253:10 0 20G 0 lvm /home</pre><pre>└─rootvg-tmplv 253:11 0 20G 0 lvm /tmp</pre><pre>sdg 8:96 0 200G 0 disk</pre><pre>└─3600a0980383143434b5d4f74574b5a2f 253:2 0 200G 0 mpath</pre><pre>├─3600a0980383143434b5d4f74574b5a2f1 253:3 0 204M 0 part /boot/efi</pre><pre>├─3600a0980383143434b5d4f74574b5a2f2 253:4 0 1G 0 part /boot</pre><pre>└─3600a0980383143434b5d4f74574b5a2f3 253:5 0 198.8G 0 part</pre><pre>├─rootvg-rootlv 253:6 0 20G 0 lvm /</pre><pre>├─rootvg-swaplv 253:7 0 16G 0 lvm [SWAP]</pre><pre>├─rootvg-optlv 253:8 0 1G 0 lvm /opt</pre><pre>├─rootvg-varlv 253:9 0 20G 0 lvm /var</pre><pre>├─rootvg-homelv 253:10 0 20G 0 lvm /home</pre><pre>└─rootvg-tmplv 253:11 0 20G 0 lvm /tmp</pre><pre>sdh 8:112 0 200G 0 disk</pre><pre>└─3600a0980383143434b5d4f74574b5a2f 253:2 0 200G 0 mpath</pre><pre>├─3600a0980383143434b5d4f74574b5a2f1 253:3 0 204M 0 part /boot/efi</pre><pre>├─3600a0980383143434b5d4f74574b5a2f2 253:4 0 1G 0 part /boot</pre><pre>└─3600a0980383143434b5d4f74574b5a2f3 253:5 0 198.8G 0 part</pre><pre>├─rootvg-rootlv 253:6 0 20G 0 lvm /</pre><pre>├─rootvg-swaplv 253:7 0 16G 0 lvm [SWAP]</pre><pre>├─rootvg-optlv 253:8 0 1G 0 lvm /opt</pre><pre>├─rootvg-varlv 253:9 0 20G 0 lvm /var</pre><pre>├─rootvg-homelv 253:10 0 20G 0 lvm /home</pre><pre>└─rootvg-tmplv 253:11 0 20G 0 lvm /tmp</pre><pre>sdi 8:128 0 512G 0 disk</pre><pre>└─3600a0980383143325a5d4f77506d7956 253:1 0 512G 0 mpath</pre><pre>sdj 8:144 0 512G 0 disk</pre><pre>└─3600a0980383143325a5d4f77506d7957 253:0 0 512G 0 mpath</pre><pre>sdk 8:160 0 512G 0 disk</pre><pre>└─3600a0980383143325a5d4f77506d7956 253:1 0 512G 0 mpath</pre><pre>sdl 8:176 0 512G 0 disk</pre><pre>└─3600a0980383143325a5d4f77506d7957 253:0 0 512G 0 mpath</pre><pre>sdm 8:192 0 200G 0 disk</pre><pre>└─3600a0980383143434b5d4f74574b5a2f 253:2 0 200G 0 mpath</pre><pre>├─3600a0980383143434b5d4f74574b5a2f1 253:3 0 204M 0 part /boot/efi</pre><pre>├─3600a0980383143434b5d4f74574b5a2f2 253:4 0 1G 0 part /boot</pre><pre>└─3600a0980383143434b5d4f74574b5a2f3 253:5 0 198.8G 0 part</pre><pre>├─rootvg-rootlv 253:6 0 20G 0 lvm /</pre><pre>├─rootvg-swaplv 253:7 0 16G 0 lvm [SWAP]</pre><pre>├─rootvg-optlv 253:8 0 1G 0 lvm /opt</pre><pre>├─rootvg-varlv 253:9 0 20G 0 lvm /var</pre><pre>├─rootvg-homelv 253:10 0 20G 0 lvm /home</pre><pre>└─rootvg-tmplv 253:11 0 20G 0 lvm /tmp</pre><p>Note that both WWID</p><p>└─3600a0980383143325a5d4f77506d7956</p><p>and</p><p>└─3600a0980383143325a5d4f77506d7957</p><p>are repeated multiple times, this is due to the RAID 5 replication setup of the disks that was provisioned to us in the BMS instance, even though they are repeated through many separate disks (sdb, sdd, sdi, sdk for the first WWID, and sde, sdc, sdj for the second WWID), we can only use each once as block storage. You may partition the disks further logically with LVM, but that’s out of the scope of this tutorial.</p><h4>4.6) Create a mountpoint for the RMAN backups, mount the CVS as a NFS volume, and momentarily grant required OS permissions so that oracle user (to be created automatically by the toolkit) can write the backups to that target</h4><p>For this exercise we will be storing the RMAN backups in a shared NFS volume created with NetApp Cloud Volume Storage.</p><p>Create a CVS Volume as per the instructions outlined in the <a href="https://cloud.google.com/solutions/partners/netapp-cloud-volumes/creating-nfs-volumes#creating_an_nfs_volume">Creating Netapp CVS NFS Volume</a> link, with the CVS Performance flag enabled (so that it is reachable from any region).</p><p>Then mount the CVS volume in your BMS server (you can grab the mount instructions for mounting your volume from the CVS volumes page in the GCP console, in our case the volume is called “nervous-elastic-skossi”). Within the volume, create a directory to store the backups, we need to provide open permissions to both the CVS mounted volume and the created directory as the oracle user needs to be able to write the first backup (the toolkit takes a first full backup once the database has been provisioned), however, the oracle user doesn’t exist yet, the toolkit creates it. Once the toolkit is finished, you can change the ownership of the backups folder to the oracle user and secure the directories if needed.</p><pre>[root@your-bms-server ~]# yum install nfs-utils</pre><pre>[root@your-bms-server ~]# mkdir /cvs-volume/</pre><pre>[root@your-bms-server ~]# sudo mount -t nfs -o rw,hard,rsize=65536,wsize=65536,vers=3,tcp 10.55.208.4:/nervous-elastic-skossi /cvs-volume</pre><pre>[root@your-bms-server ~]# cd /cvs-volume/</pre><pre>[root@your-bms-server ~]# mkdir /cvs-volume/rman_backups</pre><pre>[root@your-bms-server ~]# chmod 777 /cvs-volume</pre><pre>[root@your-bms-server ~]# chmod 777 /cvs-volume/rman_backups</pre><h3>5) Setup the jump server and run the Oracle Installation toolkit</h3><h4>5.1) Clone the BMS toolkit in the jump server and make sure all required installation files are available for the toolkit to use:</h4><p>Exit all open sessions in the BMS instance until you are back at the jump server. Alternatively you can type ~. (tilde and dot) only once to close all open sessions in the BMS server and close the ssh connection (you won’t see the characters as you type but the ssh will terminate right away and you will be back at the jump server):</p><p>Either type:</p><pre>[root@your-bms-server ~]# exit</pre><pre>[orainstall@your-bms-server ~]# exit</pre><pre>[root@your-bms-server ~]# exit</pre><pre>[customeradmin@your-bms-server ~]# exit</pre><pre>danielandres@baremetal-jump-server:~$</pre><p><strong>OR:</strong></p><pre>[root@your-bms-server ~]# ~.</pre><pre>danielandres@baremetal-jump-server:~$</pre><p>Then, <strong>in your jump-server</strong>, clone the BMS-toolkit project and run the check-swlib.sh utility to ensure all the Oracle installation files are reachable in the GCS bucket and ready to be used by the toolkit to install and patch the Oracle Database (replace <strong>BUCKET</strong> in the check-swlib.sh command with the bucket you used to place the installation files).</p><pre>danielandres@baremetal-jump-server:~$ sudo apt install git</pre><pre>danielandres@baremetal-jump-server:~$ git clone <a href="https://github.com/google/bms-toolkit">https://github.com/google/bms-toolkit</a></pre><pre>Cloning into ‘bms-toolkit’…<br>remote: Enumerating objects: 31, done.<br>remote: Counting objects: 100% (31/31), done.<br>remote: Compressing objects: 100% (24/24), done.<br>remote: Total 2010 (delta 9), reused 11 (delta 3), pack-reused 1979<br>Receiving objects: 100% (2010/2010), 828.43 KiB | 0 bytes/s, done.<br>Resolving deltas: 100% (790/790), done.<br></pre><pre>danielandres@baremetal-jump-server:~$ cd bms-toolkit/</pre><pre>danielandres@baremetal-jump-server:~/bms-toolkit$</pre><pre>danielandres@baremetal-jump-server:~/bms-toolkit$ ./check-swlib.sh — ora-swlib-bucket gs://[BUCKET]</pre><pre>Running with parameters from command line or environment variables:<br>ORA_SWLIB_BUCKET=gs://[BUCKET]<br>ORA_VERSION=19.3.0.0.0</pre><pre>Found V982063–01.zip : Oracle Database 19.3.0.0.0 for Linux x86–64</pre><pre>file size matches (3059705302), md5 matches (1858bd0d281c60f4ddabd87b1c214a4f).</pre><pre>Found V982068–01.zip : Oracle Grid Infrastructure 19.3.0.0.0 for Linux x86–64</pre><pre>file size matches (2889184573), md5 matches (b7c4c66f801f92d14faa0d791ccda721).</pre><pre>Found p29859737_190000_Linux-x86–64.zip : Oracle 19c DB RU patch 29859737 for Linux x86–64</pre><pre>file size matches (498214157), md5 matches (3b017f517341df5b35e9fbd90f1f49aa).</pre><pre>Found p29800658_190000_Linux-x86–64.zip : Oracle 19c GI RU patch 29800658 for Linux x86–64</pre><pre>file size matches (1365811472), md5 matches (13c0041a5ea7eb9fad4725d2136da627).</pre><pre>Found p29699097_190000_Linux-x86–64.zip : COMBO OF OJVM RU COMPONENT 19.4.0.0.190716 + GI RU 19.4.0.0.190716</pre><pre>file size matches (1986870968), md5 matches (2206c8a2431eb6fa0c4f7dd5aa7a58b2).</pre><pre>Found p30133178_190000_Linux-x86–64.zip : COMBO OF OJVM RU COMPONENT 19.5.0.0.191015 GI RU 19.5.0.0.191015</pre><pre>file size matches (2004604850), md5 matches (4189caeae850a7c4191fdd3fa4c0af6a).</pre><pre>Found p30463609_190000_Linux-x86–64.zip : COMBO OF OJVM RU COMPONENT 19.6.0.0.200114 GI RU 19.6.0.0.200114</pre><pre>file size matches (2308492999), md5 matches (0b2f7ae16f623e8d26905ae7ba600b06).</pre><pre>Found p30783556_190000_Linux-x86–64.zip : COMBO OF OJVM RU COMPONENT 19.7.0.0.200414 + GI RU 19.7.0.0.200414</pre><pre>file size matches (2606745994), md5 matches (f4f6a311736c61f1aa23b194f97b1ca9).</pre><pre>Found p6880880_190000_Linux-x86–64.zip : OPatch Utility</pre><pre>file size matches (118408624), md5 matches (b8e1367997544ab2790c5bcbe65ca805).</pre><p>If any of the above output fails (any of the outputs below the Found files contain “size does not match” or “md5 does not match”), DO NOT PROCEED, first obtain all the correct zip files with the patches AND the OPatch utility for the Database version you are installing and place them in the bucket accordingly, otherwise the installation will fail. Refer to the toolkit documentation for reference on the expected files and a sample of an unsuccessful output of the check-swlib.sh utility. (<a href="https://github.com/google/bms-toolkit/blob/master/docs/user-guide.md#downloading-and-staging-the-oracle-software">https://github.com/google/bms-toolkit/blob/master/docs/user-guide.md#downloading-and-staging-the-oracle-software</a>)</p><h4>5.2) Configure the required input files according to your LUN disk distribution taken from step 4.</h4><p>Modify the data_mounts_config.json and asm_disk_config.json files provided with the BMS toolkit according to the particular disk setup in your Bare Metal instance and run the installation.The toolkit uses this information to install the required mount points in the Filesystem and to setup Oracle ASM disk groups.</p><p>As described earlier, our BMS server runs RHEL, so we will allocate the selected mpaths identified in Step 4, to the Oracle binaries and to ASM as follows:</p><p>We will use WWID</p><p>└─3600a0980383143325a5d4f77506d7956</p><p>For Oracle Binaries</p><p>and</p><p>└─3600a0980383143325a5d4f77506d7957</p><p>For the DATA disk group in ASM.</p><p>So our data_mounts_config.json and asm_disk_config.json files will look like what’s displayed below (note: if you requested the BMS server with Oracle Linux, you would have to replace the content of the “blk_device” field from “/dev/mapper/WWID” to “/dev/sdX”, with X being the disk, like sdb, sdc, and so on), refer to the toolkit <a href="https://github.com/google/bms-toolkit/blob/master/docs/user-guide.md#data-mount-configuration-file">documentation</a> for additional information on disks allocation.</p><p>You may want to create an additional entry in the data_mounts_config.json file for a separate mountpoint to be used by Oracle Diag, either by pointing to another physical disk or by creating additional logical volumes with LVM in one of the disks available in your BMS server. It is also recommended to place the RECO in a separate physical disk or a separate logical volume and refer to it in another entry in the asm_disk_config.json file (for simplicity, we didn’t do any of that in this exercise).</p><p>Use nano or vi to edit the files so that they look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XckSCNTCRFPp-Huy-27wHA.png" /><figcaption>Disk allocation configured in data_mounts_config.json and asm_disk_config.json files.</figcaption></figure><h4>5.3) Transfer the private SSH key from the BMS server to the jump server and execute the installation.</h4><p>Pull the private SSH key to the jump server to be able to authenticate with it and to use for the installation.</p><pre>danielandres@baremetal-jump-server:~/bms-toolkit$ scp orainstall@100.64.50.1:/home/orainstall/bms-key ~/bms-toolkit</pre><pre>orainstall@100.64.50.1’s password:</pre><pre>bms-key 100% 1675 823.8KB/s 00:00</pre><pre>danielandres@baremetal-jump-server:~/bms-toolkit$</pre><p>Then test passwordless connectivity to the BMS server using the private key you just pulled from the BMS server. If successful an ssh session would be opened with the orainstall user in the BMS server without prompting you for any password, then <strong>REMEMBER TO exit and get back to the jump server to run the installation.</strong></p><pre>danielandres@baremetal-jump-server:~/bms-toolkit$ ssh -i bms-key orainstall@100.64.50.1</pre><pre>Last login: Sun Sep 13 05:22:05 2020 from 100.64.170.2</pre><pre>[orainstall@your-bms-server ~]$ exit</pre><pre>danielandres@baremetal-jump-server:~/bms-toolkit$</pre><p>Finally, from the jump server, run the installation script with the parameters you require for your setup. REPLACE the [BMS-server-IP-address] entry with the actual IP address of your BMS server, and the [BUCKET] argument with your bucket in GCS where the installation zip files are located. The whole installation and configuration process will take around 30–50 minutes. Make sure to export the ORA_VERSION environment variable to the Database version you’re installing.</p><pre>danielandres@baremetal-jump-server:~/bms-toolkit$ export INSTANCE_IP_ADDR=[BMS-server-IP-address]</pre><pre>danielandres@baremetal-jump-server:~/bms-toolkit$ export ORA_VERSION=19.3.0.0.0</pre><pre>danielandres@baremetal-jump-server:~/bms-toolkit$ export ORA_DB_NAME=PROD1</pre><pre>danielandres@baremetal-jump-server:~/bms-toolkit$ ./install-oracle.sh --ora-swlib-type gcs --ora-swlib-bucket gs://[BUCKET] --instance-ssh-user orainstall --instance-ssh-key bms-key --ora-edition EE --backup-dest /cvs-volume/rman_backups --ora-reco-diskgroup DATA</pre><p>You should see all the Ansible outputs as the different playgroups are executed in order. After the process is finished, your ASM and Database will be installed and patched to its latest version, database configuration, PDB creation, and RMAN Backup setup is performed and you’ve got yourself a fully functioning database, with Grid, Oracle Restart, and scheduled RMAN backups executing automatically.</p><p>There’s only one remaining step in our case, which is to revoke the wide permissions we setup earlier on the CVS NFS volume:</p><p>Jump into the BMS instance, and change permissions and ownership of the proper folders. You may also check out the Oracle installation while you’re in there as well:</p><pre>danielandres@baremetal-jump-server:~/bms-toolkit$ ssh -i bms-key orainstall@100.64.50.1</pre><pre>Last login: Sun Sep 13 05:32:33 2020 from 100.64.170.2</pre><pre>[orainstall@your-bms-server ~]$ sudo su</pre><pre>[root@your-bms-server ~]$ chown oracle:asmadmin /cvs-volume/rman_backups</pre><pre>[root@your-bms-server ~]$ chmod 740 /cvs-volume/rman_backups</pre><pre>[root@your-bms-server ~]$ su - grid</pre><pre>[grid@your-bms-server ~]$ asmcmd -P</pre><pre>ASM&gt; ls</pre><pre>PROD1</pre><pre>ASM&gt; ls PROD1</pre><pre>DATA</pre><pre>ASM&gt;cd PROD1/DATA</pre><pre>ASM&gt;</pre><pre>[grid@your-bms-server ~]$ exit</pre><p>Finally, you may want to turn down the Internet Gateway machine so that the newly provisioned Database doesn’t have connectivity to the Internet.</p><p>And that’s it !!</p><p><a href="https://medium.com/u/d6cd69777bc8">Valavan Rajakumar</a> and <a href="https://medium.com/u/c83442440f33">Daniel Villegas</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=47f5ab594821" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/from-zero-to-hero-production-ready-oracle-database-in-minutes-with-bms-toolkit-using-bare-metal-47f5ab594821">From zero to hero: Production-ready Oracle Database in minutes with BMS-Toolkit using Bare Metal…</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>