google-cloud-platform #google- cloud- platform 1 1: google-cloud-platform 2 2 Examples 2 2 2: .NET Cloud Resource Manager API 3 3 3 Examples 5 5 6 Google (!) (!) 6 3: Apps Google Cloud SQL ? 8 Examples 8 Google Cloud SQL Apps ( : Google App Engine) (mySQL Workbench) ? 8 4: Google App Engine 11 11 Examples 11 PHP app.yaml 11 gcloud cli 11 11 PHP Cloud SQL 12 12 12 5: Python Cloud Resource Manager API 13 13 13 Examples 14 14 Google (!) (!) 15 16 18 You can share this PDF with anyone you feel could benefit from it, downloaded the latest version from: google-cloud-platform It is an unofficial and free google-cloud-platform ebook created for educational purposes. All the content is extracted from Stack Overflow Documentation, which is written by many hardworking individuals at Stack Overflow. It is neither affiliated with Stack Overflow nor official google-cloud- platform. The content is released under Creative Commons BY-SA, and the list of contributors to each chapter are provided in the credits section at the end of this book. Images may be copyright of their respective owners unless otherwise specified. All trademarks and registered trademarks are the property of their respective company owners. Use the content presented in this book at your own risk; it is not guaranteed to be correct nor accurate, please send your feedback and corrections to [email protected] https://riptutorial.com/ko/home 1 1: google-cloud-platform google-cloud-platform . google-cloud-platform . google-cloud-platform . Examples google-cloud-platform . google-cloud-platform : https://riptutorial.com/ko/google-cloud-platform/topic/6864/google-cloud- platform- https://riptutorial.com/ko/home 2 2: .NET Cloud Resource Manager API .NET Google API . Google . API . ... packages.config project.json . Program.cs . using System; using System.Collections.Generic; using System.Threading.Tasks; using Google.Apis.Auth.OAuth2; using Google.Apis.CloudResourceManager.v1; using Google.Apis.Services; using Data = Google.Apis.CloudResourceManager.v1.Data; namespace OurFirstProject { public class Program { private const string projectId = [YOUR-PROJECT-ID]; private const string applicationName = "Test"; public static void Main(string[] args) { var scopes = new String[] { CloudResourceManagerService.Scope.CloudPlatform }; GoogleCredential credential = Task.Run( () => GoogleCredential.GetApplicationDefaultAsync() ).Result; if (credential.IsCreateScopedRequired) { credential = credential.CreateScoped(scopes); } CloudResourceManagerService service = new CloudResourceManagerService( new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = applicationName } ); https://riptutorial.com/ko/home 3 Console.WriteLine("1. Create Project"); Data.Operation operation1 = service.Projects.Create( new Data.Project() { ProjectId = projectId, } ).Execute(); Console.Write("2. Awaiting Operation Completion"); Data.Operation operation2; do { operation2 = service.Operations.Get(operation1.Name).Execute(); Console.WriteLine(operation2.Done.ToString()); System.Threading.Thread.Sleep(1000); } while (operation2.Done != true); Console.WriteLine(); Console.WriteLine("Enter to continue"); Console.ReadLine(); Console.WriteLine("3. Deleting Project"); var operation3 = service.Projects.Delete(projectId).Execute(); } } } Windows Visual Studio "" Linux dotnet restore dotnet run . Compiling Projects for .NETCoreApp,Version=v1.1 Compilation succeeded. 0 Warning(s) 0 Error(s) Time elapsed 00:00:01.4161926 1. Create Project 2. Awaiting Operation Completion True Enter to continue 3. Deleting Project https://riptutorial.com/ko/home 4 " " "" () . Examples Windows Linux . .NET Core .NET Standard . .NET project.json . .NET Standard packages.config packages.config . Cloud Resource Manager API API nuget . https://www.nuget.org/packages/Google.Apis.CloudResourceManager.v1/ 1.22.0.809. • .NET Windows; • .NET Linux. Windows Visual Studio "Visual C #" " " . packages.config . packages.config .NET Standard .NET Windows . Windows .NET Standard . packages.config . <?xml version="1.0" encoding="utf-8"?> <packages> <package id="Google.Apis" version="1.22.0" targetFramework="net452" /> <package id="Google.Apis.Auth" version="1.22.0" targetFramework="net452" /> <package id="Google.Apis.CloudResourceManager.v1" version="1.22.0.809" targetFramework="net452" /> <package id="Google.Apis.Core" version="1.22.0" targetFramework="net452" /> </packages> project.json . project.json .NET Core Linux .NET Core . Linux Windows .NET Core . project.json . { "version": "1.0.0-*", "buildOptions": { "debugType": "portable", "emitEntryPoint": true }, "dependencies": {}, "frameworks": { "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "type": "platform", "version": "1.1.0" }, https://riptutorial.com/ko/home 5 "Google.Apis.CloudResourceManager.v1":"1.22.0.809" }, "imports": "dnxcore50" } } } . " Google API ." . API Application Default Credentials . gcloud auth application-default login [[email protected]] Application Default Credentials . var scopes = new String[] { CloudResourceManagerService.Scope.CloudPlatform }; GoogleCredential credential = Task.Run( () => GoogleCredential.GetApplicationDefaultAsync() ).Result; if (credential.IsCreateScopedRequired) { credential = credential.CreateScoped(scopes); } ... () Google Cloud API . credential Google . Google (!) (!) Google Google . , credential . CloudResourceManagerService service = new CloudResourceManagerService( new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = "Our First Google API Client" } ); . ? https://cloud.google.com/resource-manager/docs/apis Projects.Create REST ? https://riptutorial.com/ko/home 6 https://cloud.google.com/resource-manager/reference/rest/v1/projects/create OK ... projectId projectId . ID . Projects.Create Data.Project Data.Project . Project ID , , . Data.Operation operation1 = service.Projects.Create( new Data.Project() { ProjectId = projectId, } ).Execute(); . Operation . Name . " ?" . True Done . Data.Operation operation2; do { operation2 = service.Operations.Get(operation1.Name).Execute(); System.Threading.Thread.Sleep(1000); } while (operation2.Done != true); , . Projects.Delete ID . var operation3 = service.Projects.Delete(projectId).Execute(); ! .NET Cloud Resource Manager API : https://riptutorial.com/ko/google-cloud- platform/topic/9523/-net--cloud-resource-manager-api----- https://riptutorial.com/ko/home 7 3: Apps Google Cloud SQL ? Examples Google Cloud SQL Apps ( : Google App Engine) (mySQL Workbench) ? Google Cloud SQL Google App Engine MySQL Workbench . Google Cloud SQL : Google Cloud SQL MySQL , , . Google Cloud SQL App Engine . Cloud SQL Google MySQL . : https://cloud.google.com/sql/ https://cloud.google.com/sql/docs/ SQL : Google Cloud SQL Google MySQL . 1. Google Cloud Platform Console ( https://console.cloud.google.com/sql/instances) Cloud SQL Instances Create instance . 2. First Generation Create . 3. 4. > root (root_password) . MySQL 'root'@ '%' . 5. (DataBase_Name) . MySQL Workbench : MySQL Workbench , DBA . MySQL Workbench , , , SQL . http://www.mysql.com/products/workbench/ . MySQL Workbench Google Cloud SQL . 1. Google Cloud Platform Console Cloud SQL . 2. > IP IPv4 adddress (Instance_IPv4_address). Google Cloud SQL MySQL Workbench . : $ 0.01 IPv4 $ 0.1 1. IP Google 'ip address' https://riptutorial.com/ko/home 8 2. > > IP . 3. > (userName), (password) ' ' . WorkBench . 1. MySQL Workbench . 1. , . 1. 1. MySQL OK SQL Editor . Google App Engine : Google App Engine . App Engine . https://cloud.google.com/appengine . App Engine Cloud SQL . 1. Google Cloud Platform Console Cloud SQL . 1. > > App Engine ID ID . 1. > ' '(Instance_Connection_Name) 1. Google war / WEB-INF / appengine-web.xml true </ use-google-connector-j> : Google App Engine - Java public static Connection connect() throws ClassNotFoundException, SQLException { String url = null; { if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Production) { // Connecting from App Engine. Class.forName(Messages.getString("com.mysql.jdbc.GoogleDriver")); url = Messages.getString("jdbc:google:mysql://{{Instance_Connection_Name}}/{{DataBase_Name}}?user=root&password={{root_password}}"); } else { // Connecting from an external network or localhost Class.forName(Messages.getString("com.mysql.jdbc.Driver")); url = Messages.getString("jdbc:mysql://{{Instance_IPv4_address}}:3306/{{DataBase_Name}}?user={{userName}}&password={{password}}"); } Connection conn = DriverManager.getConnection(url); return conn; } https://riptutorial.com/ko/home 9 } Apps Google Cloud SQL ? : https://riptutorial.com/ko/google-cloud-platform/topic/10772/apps--- google-cloud-sql--- https://riptutorial.com/ko/home 10 4: Google App Engine Google App Engine (GAE) Google Cloud Platform Platform as a Service (PaaS) , . App Engine . App Engine Standard Flexible Go, Java, Python, PHP, Node.JS, Ruby .NET . Examples PHP app.yaml runtime: php vm: true api_version: 1 runtime_config: document_root: web gcloud cli Google Cloud SDK gcloud . $ curl https://sdk.cloud.google.com | bash Google . $ gcloud auth login gcloud . $ gcloud init gcloud . $ gcloud info SDK . $ gcloud config list . $ gcloud auth list . https://riptutorial.com/ko/home 11 $ gcloud help PHP Cloud SQL Cloud SQL $dsn = "/cloudsql/PROJECT:REGION:INSTANCE;dbname=DATABASE"; $user = "USER"; $password = "PASSWORD"; $db = new PDO($dsn, $user, $password); //Whatever is your favorite MySQL connection method /cloudsql/PROJECT:REGION:INSTANCE; . Unix Cloud SQL . Instance connection
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages21 Page
-
File Size-