Hi Cam,
Yes, you can use Azure DevOps to provision Google Cloud Platform (GCP) resources.
Here is a step-by-step guide based on a practical example of deploying a Google Cloud function to GCP using Azure DevOps:
Setting up a Google Service Account
- Log in to the GCP Console.
- Select your project.
- Activate Cloud Shell.
- Set default configuration values:
-
gcloud config set project [PROJECT_ID]
-
gcloud config set compute/zone [ZONE]
- Create a Service Account:
-
gcloud iam service-accounts create azure-pipelines-publisher --display-name "Azure Pipelines Publisher"
- Assign the Storage Admin IAM role to the service account:
- Execute a series of commands to set the project number, get the service account email, and assign the role.
Storing Service Account Key in Azure DevOps
- Navigate to IAM & Admin / Service Accounts in GCP and edit the service account you created.
- Create a key and download it.
- In Azure DevOps, go to the Library under Pipelines and select "Secure Files".
- Upload the key and authorize it for all pipelines.
Creating CI/CD Pipeline in Azure DevOps
- Use the secure key by adding the
DownloadSecureFile@1
task in your pipeline YAML. - Install Google Cloud SDK on the Azure pipeline agent if it's not pre-installed. This can be done by downloading and installing the SDK via script commands.
- Deploy the function using a script:
- Authenticate using the service account key.
- Deploy the function with a command like **
gcloud functions deploy [FUNCTION_NAME] --runtime nodejs8 --trigger-http --region=[REGION] --project=[PROJECT_ID]
**.
Hope this helps!