In this post, I will show you how DevOps practices can add value to a variety of Office 365 development scenarios. The practices we will discuss are Infrastructure as Code, Continuous Integration, and Continuous Delivery. The advances in DevOps and SharePoint Framework (SPFx) have allowed us to make advancements in the way that we develop software and have improved our efficiency.
Infrastructure as Code (IaC)
Practicing IaC means that the infrastructure your applications depend on is created and maintained by code that is source controlled, tested, and deployed to production much like software. When discussing IaC, we’re typically talking about provisioning resources to a cloud provider. In our case, the “infrastructure” is Office 365 – a SaaS product with extensive customization and configuration options.
While you could manage your O365 tenant with PowerShell, the code-centric and template-based PnP Provisioning Framework aligns better with this practice because:
- Using the frameworks declarative XML syntax, you describe what you want to exist rather than writing code to manage how it gets created.
- It is easier for developers to run idempotent deployments to enact the desired state of your Office 365 tenant.
While originally developed to support SharePoint Online and on-premise deployments, you can see in its latest schema that it has expanded to support Microsoft Teams, OneDrive, and Active Directory.
Continuous Integration (CI)
The practice of continuously integrating first means that your team has established the habit of frequently merging small batches of changes into a central code repository. Upon that merge, we automatically build and test the code to quickly identify bugs and quality issues.
SharePoint Framework is a commonly used tool used to extend the capabilities of SharePoint Online and on-premise. Much like the Provisioning Framework, SharePoint Framework is expanding to support other Office 365 services. You can currently use it to develop for Microsoft Teams and will soon be able to use it to develop Office Add-Ins.
Azure DevOps is a one-stop-shop service that provides everything you need throughout the software development lifecycle. For example, your team can version control your project’s source code in Repos. After merging changes, use Pipelines to trigger a CI process that runs the build and test tasks of your SharePoint Framework solution.
Continuous Delivery (CD)
Continuous Delivery, the practice of running automated deployments through a sequence of environments, starts after a completed CI process. Azure DevOps Pipelines will again be the tool of choice to execute the deployment procedures against each environment.
A solution demonstrating how to use the technologies and practices described above is available on Applied Information Science’s GitHub account. The result is a pipeline capable of receiving frequent changes to O365 configuration and SPFx applications from 1 or many developers, verifying the quality of the change, and deploying it to a series of environments.
I encourage you to explore the source code using the following summary as a guide. You’ll find the solution organized into three areas – SPFx, Provisioning, and Pipeline.
The PnP Provisioning Template XML file found here defines the desired state of the target tenant. The following is the desired state:
- Install the SPFx App into the tenant App Catalog.
- Create a site collection that will host our web parts page.
- Install the SPFx App to the Site Collection.
- Create a page that will host our web part.
- Add the web part to the page.
By using parameters for the tenant URL and site owner, the same template can be deployed to multiple environments. A PowerShell build script bundles the template and all required files, such as the SPFx sppkg file, into a single pnp file ready for deployment.
A multi-stage YAML pipeline defined in the Pipeline folder of the example solution runs the following process:
- Build, test, and package the SPFx and Provisioning Template source code.
- Deploy the prerequisite SharePoint infrastructure to the tenant if it does not already exist.
- Install and configure the SPFx web part.
- Repeat #2 and #3 for all environments.
Secret variables, such as the username and password used to connect to the tenant, are only referenced in the pipeline. The values are set and encrypted in the Azure DevOps pipeline editor.
In the not-too-distant past, it was high effort to write unit tests for a SharePoint solution, and most deployments were manual. In this post, I have shown you how advancements in the platform and tooling have changed this. The mentality, practices, and tools brought by DevOps can improve the pace and quality of any software development and infrastructure management project, including projects building upon Office 365.