IoT Code Deployment

IoT Code Deployment


Infrastructure as code (IaC) Deployment ?

Infrastructure as a code (IaC) is a practice in software engineering that involves managing and provisioning computer infrastructure through machine-readable configuration files, rather than manual configuration. With IaC, developers can treat infrastructure as they would any other code, allowing them to version control and automate the deployment, management, and scaling of their infrastructure.

IaC tools typically work by defining infrastructure configurations in a declarative language or domain-specific language (DSL), which can then be used to automatically provision and configure the necessary resources on cloud providers like Amazon Web Services (AWS), Microsoft Azure, or Google Cloud Platform (GCP). This approach helps to minimize errors and inconsistencies that can occur when manually configuring infrastructure.

Architecture of Blog

• Azure Portal Prerequisite

• Azure DevOps portal Prerequisite

• Step for run code pipeline on Azure DevOps portal

Azure Portal Prerequisite

Step 1: Sign-in to the Azure portal.

Step 2: Create Resource Group on azure portal with following naming pattern.

(How to create Resource Group on azure portal)

Resource Group:

• ICPL-IT-IoT-Automation-RG-Connectivity

• ICPL-IT-IoT-Automation-RG-Common

• ICPL-IT-IoT-Automation-RG-UsecaseOne

• ICPL-IT-IoT-Dev-Terraform (Store .tfstate file)

Storage Account: (Inside ICPL-IT-IoT-Dev-Terraform resource Group)

• icplitiotdevstrgterraform

Container: (inside icplitiotdevstrgterraform Storage account)

• icpl-it-iot-dev-cnt-common

• icpl-it-iot-dev-cnt-connectivity

• icpl-it-iot-dev-cnt-usecaseone

Step 3: Create Service principal on azure portal with following naming pattern.

(How to create service principal on azure portal)

Service Principal: • ICPL-IT-IoT-Dev-Terraform

Step 4: Assign permission to service principal using azure portal.

(How to Assign permission to service principal)

Service Principal: ICPL-IT-IoT-Dev-Terraform Role: Contributor Resource Group: ICPL-IT-IoT-Automation-RG-Connectivity ICPL-IT-IoT-Automation-RG-Common ICPL-IT-IoT-Automation-RG- UsecaseOne ICPL-IT-IoT-Dev-Terraform

Azure DevOps Portal Prerequisite

Step 1: Sign-in to Azure DevOps

Step 2: Create Private project in azure DevOps.

(How to create project in azure devOps portal)

Project Name: ICPL-IoT-Dev-ConnectivityICPL-IoT-Dev-Common ICPL-IoT-Dev-UsecaseOne

Step 3: Install Extension

(How to add free extension (terraform))

Add terraform extension into azure devOps portal.

Step 4: Create Service Connection in azure DevOps using Resource Group

(How to create service connection)

Create Service connection for each Project in azure DevOps portal and follow the following naming pattern for service connection.

Project Name: ICPL-IoT-Dev-Connectivity

Service Connection: ICPL-IT-IoT-Dev-Connectivity-SC

Project Name: ICPL-IoT-Dev-Common

Service Connection: ICPL-IT-IoT-Dev-Common-SC

Project Name: ICPL-IoT-Dev-UsecaseOne

Service Connection: ICPL-IT-IoT-Dev-UsecaseOne-SC

Step 5: Create Variable Group using classic in azure DevOps Portal.

(How to create variable group classic in azure devOps portal)

Project Name:

ICPL-IoT-Dev-Connectivity

Variable group name:

ICPL-IT-IoT-Dev-VG-Connectivity

Variables

NameValue
backendAzureRmContainerNameicpl-it-iot-dev-cnt-connectivity
backendAzureRmKeyicpl-it-iot-dev-cnt-connectivity.tfstate
backendAzureRmResourceGroupNameICPL-IT-IoT-Dev-Terraform
backendAzureRmStorageAccountNameicplitiotdevstrgterraform
backendServiceArmICPL-IT-IoT-Dev-Connectivity-SC
tfvarsFileNameterraform-dev.tfvars

Project Name:

ICPL-IoT-Dev-Common

Variable group name:

ICPL-IT-IoT-Dev-VG-Common

Variables

NameValue
backendAzureRmContainerNameicpl-it-iot-dev-cnt-common
backendAzureRmKeyicpl-it-iot-dev-cnt-common.tfstate
backendAzureRmResourceGroupNameICPL-IT-IoT-Dev-Terraform
backendAzureRmStorageAccountNameicplitiotdevstrgterraform
backendServiceArmICPL-IT-IoT-Dev-Common-SC
tfvarsFileNameterraform-dev.tfvars

Project Name:

ICPL-IoT-Dev-UsecaseOne

Variable group name:

ICPL-IT-IoT-Dev-VG-UsecaseOne

Variables

NameValue
backendAzureRmContainerNameicpl-it-iot-dev-cnt-usecaseone
backendAzureRmKeyicpl-it-iot-dev-cnt-usecaseone.tfstate
backendAzureRmResourceGroupNameICPL-IT-IoT-Dev-Terraform
backendAzureRmStorageAccountNameicplitiotdevstrgterraform
backendServiceArmICPL-IT-IoT-Dev-UsecaseOne-SC
tfvarsFileNameterraform-dev.tfvars

What is terraform ?

Terraform uses a declarative configuration language to define infrastructure as code, enabling teams to version, manage, and share their infrastructure configurations.

With Terraform, users can define their infrastructure requirements using a high-level, human-readable language, and then use Terraform to create, update, and delete resources as necessary. Terraform supports a wide range of cloud providers, including Amazon Web Services (AWS), Microsoft Azure, Google Cloud Platform (GCP), and many others.

Declarative configuration: Terraform configurations define the desired state of infrastructure, rather than how to achieve that state. This approach allows users to manage infrastructure as code, rather than through manual configuration.

Resource management: Terraform provides a unified interface for managing a wide range of cloud resources, including virtual machines, databases, load balancers, and more.

Plan execution: Terraform executes changes in a planned and controlled manner, reducing the risk of errors or unexpected outcomes.

Collaboration: Terraform supports version control systems, enabling teams to collaborate and share infrastructure configurations.

Step 6: Add (azure)Terraform Script to Bitbucket

Terraform script content multiple resources going to create for azure resource group such like virtual network, iothub, event grid system topic, storage account, function app and so on.

Create private repo with name “infra-automation”. Push terraform script into your Bitbucket account. It helps when we push any changes on script that time pipeline trigger automatically.

Step-1

One approach to code deployment is to use a continuous deployment (CD) pipeline, which automates the entire deployment process, from building and testing to deployment and monitoring. CD pipelines can help to reduce the risk of errors and enable teams to deploy changes more frequently, which can lead to faster innovation and a more responsive software development process.

Azure CI/CD Pipeline is a cloud-based continuous integration and continuous delivery service provided by Microsoft Azure. It enables developers to automatically build, test, and deploy their applications to any Azure service or on-premises server. Azure CI/CD Pipeline supports a variety of languages, frameworks, and platforms, including .NET, Java, Node.js, Python, and many others.

Step 7: Create New Pipeline.

Step-2

Step 8: “Use the Classic editor” to create a pipeline

Step-3

Step 9: Select Bitbucket Cloud option and authorized your Bitbucket

We have added terraform script into Bitbucket to integrate Bitbucket with azure DevOps. we must choose Bitbucket Cloud option for this. First , we must authorize our Bitbucket account with Azure DevOps.

Select any of bellow method for authentication.

Authentication typePipelines run using
OAuthYour personal Bitbucket identity
Username and passwordYour personal Bitbucket identity
Step-4

Step 10: Select Bitbucket Cloud option and authorize your Bitbucket account, then select repository and branch, and click “Continue”.

Select repository “infra-automation” which we created in Bitbucket account and select branch where we pushed our terraform script.

Step-5

Step 11: In Configuration as code select “YAML” option and click “Apply”

Step-6

Step 12: Browse “YAML file path” from Bitbucket repo.

Step-7

Step 13: In Variable tab select “Variable groups” and “Link variable group”.

Step-8

Step 14: Link Variable group which we already created in step 5.

Step-9

Step 15: After Link variable group save and queue.

Step 16: In Library tab select variable group which we linked with pipeline and give “Pipeline permission” to that created pipeline and click Save.

Step-10

Step 17: Run Created pipeline.

After Successfully running pipeline, we must give permission to pipeline , for that we must to click on “permit” option and pipeline going to running mode.

Conclusion

In conclusion, code deployment is a critical process in software development that involves delivering code changes to production environments. The goal of code deployment is to ensure that software changes are deployed quickly and reliably, while minimizing the risk of downtime or errors.



Solutions

Solutions

Services

Services