AZ - 400 DevOps Engineer        17

The broad range of topic        17

Scenario        17

Chap -1: Developing an Actionable Alerting Strategy        18

SRE - Site Reliability Engineering        18

What is reliability:        18

Measuring reliability        18

What is SRE        18

Why do we need SRE        19

Key concepts        19

SRE vs. DevOps        20

Summary        20

Exploring metrics charts and dashboards        21

Intro to Azure monitoring        21

Azure Monitor metrics overview        21

Demo        21

1. Create a chart to view metrics        22

2. Add additional metrics and resources        22

3. Add charts to dashboards        22

Summary        22

Implementing application Health checks        22

Scenario        22

What is Application Insight        23

Availability        23

Demo        23

1. Configure URL ping test        24

2. Configure health alert        24

Summary        24

Discovering service and resource health alerts        24

Azure status        24

Service health        24

Resource health        25

Demo        25

1. Azure status page - https://status.azure.com/en-ca/status        26

2. View service health pages and create alerts        26

3. View resource health and create alerts        26

Summary        27

Self-healing alerts        27

Scenario        27

Vertical vs horizontal scaling        27

App Service vs. VMSS(Vitual machine scale set)        28

Autoscaling process        28

Demo        28

1. Configure autoscale notifications for App service and VMSS        28

Summary        29

Chap - 2: Designing Failure Prediction Strategy        29

Introduction        29

Exploring System load and failure conditions        29

Everything fail sometimes        29

What is failure mode analysis?        30

How to plan for failure        30

How can we reduce failure?        30

Performance Testing        31

Summary        31

Understanding failure prediction        31

You cannot prepare for everything        31

What is predictive maintenance PdM        31

How Microsoft used to do PdM        32

How does Microsoft do PdM now        33

Summary        33

Understanding baseline metrics        34

Scenario        34

Why create baseline        34

How to create baseline        34

Demo        35

1. Explore Azure monitor insight        36

Summary        36

Discovering Application Insight smart detection and dynamic threshold        36

Scenario        36

Dynamic threshold advantages        36

Application Insights smart detection        36

Smart detection categories        36

Demo        37

1. Create an alert which dynamic thresholds        37

2. Create smart detection alerts        37

Summary        38

Summary        38

Chap - 3: Designing and Implementing Health Check        38

Deciding which dependencies to set alerts on        38

What is a dependency?        38

Application Insights dependency tracking        39

Which dependencies are tracked in Application Insights        39

Where can I find dependency data        40

Application dependencies on virtual machines        40

Demo exploring dependencies        40

Summary        41

Exploring service level objectives SLO        42

What makes an SLO?        42

How is an SLO helpful?        42

SLO’s and response time-outs        42

Demo: Configure Azure SQL to meet SLO‘s        43

Call outs        44

Summary        44

Understanding partial health situation        44

Health monitoring        44

Health monitoring data        44

Telemetry correlation        45

Application logs best practices        45

Endpoint health monitoring        46

Summary        46

Improving recovery time        46

Why do we need a recovery plan        46

High availability(HA) Vs disaster recovery(DR)        47

Recovery Point Objective(RPO) Vs  Recovery Time Objective(RTO)        47

Business continuity strategies        47

RTO improvement options        48

Azure services that help reduce RTO        50

Summary        50

Exploring computer resource health checks        51

App service Health checks        51

Customize Web App health checks        51

VMSS Health extension        51

Container health check types        52

Liveness Check Example        52

Startup Check Example        53

Readiness Check example        53

Summary        54

Summary        54

Chap - 4: Developing a modern Source Control Strategy        56

Introduction to source control        56

What is source control        56

Source control types        56

Which one to use?        57

Summary        57

Exploring Azure repos        57

Azure repos at a glance        57

Setting up Azure Repos        57

Import options        57

Supported GIT features        57

Summary        58

Azure Repos demo and Git workflow        58

Repository sharing with submodule        58

What are submodules        58

How submodule works        59

Submodules in Azure DevOps        59

Demo: adding submodule to repo        59

Summary        60

Summary        60

lab: authenticate to Azure repose using an authentication token        61

Chap - 5: Planning and implementing branching strategies for the source code        62

Configure branches        62

What is a branch        62

Branch management        62

Summary        63

Discovering Branch Strategies        63

Branch strategies        63

● Trunk-based branching        63

● Feature(task) branching        64

● Feature flag branching        64

● Release branching        64

Summary        64

Pull request workflow        64

What is pull request        65

Goals        65

What’s in the pull request        65

Pull request workflow        65

Summary        65

Code reviews        65

How can you make code reviews efficient        66

1. Code review assignments        66

2. Schedule reminders        66

3. Pull analytics        66

Demo        66

Summary        66

Static code analysis        66

Guidelines for effective code review        66

Code quality tools        67

Demo        67

Summary        67

Useful requests with work items        67

The importance of relating work items        67

Demo        67

Summary        67

Lab:  Configure branch policies in Azure Repos        67

Summary        68

Chap - 6: Configuring Repositories        70

Using Git tags to organize your repository        70

What are Git tags, and why do we care?        70

Tag types and how they work        70

Demo + Tags in Azure repos        71

Summary        71

Handling large repositories        71

Challenges of Large repos        71

Working with Git large file storage LFS        71

Best practices for working with large files        72

Clean up with git gc        72

Summary        72

Exploring repository permissions        73

Branch permissions in Azure repos        73

How branch permissions work        73

Branch locks        73

Demo: working with branch permissions/locks        74

Summary        74

Removing repository data        74

Challenges of removing Git Data        74

Unwanted file states        74

File removal scenario        74

Demo: Removing Unwanted files from Azure repo        75

Summary        75

Recovering repository data        75

Recovery scenarios        75

Revert to previous commit        76

Restore deleted branch from Azure repos        76

Restore deleted Azure repository        76

Demo: recover deleted branch        76

Summary        76

Summary        76

Chap - 7: Integrating source control with tools        78

Connecting to GitHub using Azure active directory        78

Advantage of AAD integration        78

Requirements for connecting to AAD        78

Azure AD SSO configuration        78

GitHub enterprise configuration        79

Summary        79

Introduction to GitOps        79

What is GitOps        79

Sample GitOps workflow        79

Exam perspective        80

Summary        80

Introduction to ChatOps        80

What is ChatOps        81

How to connect Chat apps to Azure DevOps        81

Demo        81

Summary        82

Incorporating Changelogs        82

What is GIT Changelogs?        82

Manually creating/viewing Changelogs        83

Automation options        83

Demo viewing Changelogs via command line        83

Summary        83

Summary        83

Chap - 8: Implementing a build strategy        84

Getting started with Azure pipelines        85

What are Azure pipelines        85

Importance of automation        85

Pipeline basic/structure/trigger        86

Summary        87

Azure pipeline demo        87

Integrate source control with Azure DevOps pipelines        88

Source control options        88

GitHub, Subversion        88

Demo        88

Summary        89

Understanding build agents        89

Role of agent        89

Microsoft and self-hosted agent        89

Parallel jobs        90

Demo        90

Exploring self hosted build agents        90

Self-hosted agent scenario        91

Self-hosted agent communication process        91

Agent pools        91

Demo        91

Summary        92

Using build trigger rules        92

Trigger types        93

Summary        94

Incorporating multiple builds        94

Multiple Build scenario        95

Demo        95

Summary        96

Exploring containerized agents        97

Why run a pipeline job in a container        97

Microsoft hosted agent configuration        97

Non-orchestration configuration(manual)        98

Orchestration configuration(AKS)        100

Summary        100

Summary        100

Lab: Use deployment groups in Azure DevOps to deploy a .net app        103

Lab: Integrate GitHub with Azure DevOps pipelines        104

Chap - 9: Designing a package management strategy        104

Introduction        104

What is package manager/software package        104

Discovering Package Management Tools        105

Development-related package managers (perspective)        105

How to manage packages        105

Package hosting service example        106

Summary        106

Exploring Azure artifact        106

Azure artifact        106

Feeds        106

Developer workflow with Visual Studio        106

Demo: Connecting to feeds in visual studio        107

Summary        107

Creating a versioning Strategy for Artifact        108

Proper versioning strategy        108

Versoning recommendations        108

Feed views        108

Demo        108

Summary        108

Summary        109

Chap - 10: Designing Build automation        109

Integrate external services with Azure pipelines        110

Scenarios for connecting external tools        110

External tool connection methods        110

Popular code scanning service/tools        111

Summary        111

Visual Studio Marketplace Demo        111

Exploring Testing Strategies in your build        112

Why test code?        112

Testing methodologies        112

Azure test plans        112

Summary        112

Understanding code coverage        113

What is Code Coverage        113

How code coverage tests work        113

Code coverage frameworks        114

Demo        114

Summary        114

Summary        114

LAB: Create and Test an ASP.NET Core App in Azure Pipelines        116

Lab: Use Jenkins and Azure DevOps to Deploy a Node.js App        116

Chap - 11: Maintaining a build strategy        117

Introduction        117

Discovering pipeline health monitoring        117

Scenarios for monitoring pipeline health        118

Pipeline reports        118

1. Pipeline pass rate        118

2. Test pass rate        118

3. Pipeline duration        118

Demo        118

Summary        118

Improving build performance and cost efficiency        119

Build performance and costs        119

Pipeline caching        119

Self-hosted agents        119

Agent Pull consumption reports        120

Summary        120

Exploring build agent analysis        120

Scenario: Troubleshoot Pipeline Failures        120

Viewing logs        120

Downloading logs        121

Configure verbose logs        121

Demo        121

Summary        121

Summary        121

Chap - 12: Designing a process for standardizing builds across organization        122

Implementing YAML templates        122

YAML template purpose        122

Inserting templates        122

Template location reference        122

Demo        125

Summary        125

Incorporating valuable groups        125

Variable group purpose        125

Pipeline variables        125

Creating variable groups        125

Using variable groups        127

Demo        127

Summary        127

Summary        127

Chap - 13: Designing an application infrastructure management strategy        128

Exploring configuration management        128

What is configuration management        128

Assessing Configuration Management Mechanism        128

1. Mutable infrastructure        128

2. Imperative and declarative code        129

3. Abstraction        129

4. Simplified code process        130

Centralization        130

Agent-based management        131

Summary        131

Introducing PowerShell Desired State Configuration (DSC)        131

Aspect of PowerShell DSC        131

Important consideration of PowerShell DSC        132

Anatomy of PowerShell DSC        132

Summary        132

Implementing PowerShell DSC for app infrastructure        132

Primary uses for PowerShell DSC        132

Demo: Setup PowerShell DSC for DevOps pipeline        133

Summary        133

Summary        133

Lab create a CICD pipeline using PowerShell DSC        134

Chap - 14: Developing Deployment Scripts and Templates        134

Understanding deployment solution options        134

Deploying code        134

Deployment solution        135

Aspects of a deployment        135

Topics for evaluating deployment solutions        136

Summary        136

Exploring infrastructure as code: ARM vs. Terraform        136

Comparison        136

Code differences        136

Demo: ARM template in Azure pipeline        136

Demo: deploying terraform in Azure pipeline        137

Summary        138

Exploring infrastructure as code: PowerShell vs. CLI        138

Code differences        138

Comparison highlights        138

Demo: Deploying with both PowerShell and CLI        138

Summary        139

Linting ARM Templates        139

What is linting        139

Demo        139

Summary        139

Deploying a Database        140

What is DACPAC?        141

Demo        141

Summary        141

Understanding SQL Data Movement        141

What is BACPAC?        141

Demo        142

Summary        142

Introduction to Visual Studio App Center        143

What is App Center        143

Demo        143

Summary        143

Exploring CDN and IOT deployments        143

Azure CDN deployment with DevOps pipeline        144

Azure IOT Edge deployment with DevOps pipeline        144

Demo        144

Summary        144

Understanding Azure Stack and sovereign cloud deployment        145

Exploring environments        145

Demo        145

Summary        146

Summary        146

Lab: Build and Distribute an app in App center        146

Lab: Linting your ARM templates with Azure pipelines        150

Lab: Building infrastructure with Azure pipeline        151

Lab: Deploy a python app to an AKS cluster using Azure pipeline        151

Chap - 15: Implementing an Orchestration Automation Solution        152

Exploring release strategy        152

Canary deployment        152

Rolling deployment        152

Blue/Green deployment        152

Summary        153

Exploring stages, dependencies and conditions        153

Release pipeline stage anatomy        153

Stages        153

Dependencies        154

Conditions        154

Full stage syntax        154

Summary        154

Discovering Azure app configuration        155

The INI File        155

How can you deploy app configurations?        156

What is Azure app configuration        156

Azure app configuration benefits        156

Demo        157

Summary        157

Implementing release gates        157

What are gates        157

Scenarios for gates        157

1. incident and issues management        157

Manual intervention and validations        158

Demo        158

Summary        158

Summary        158

Lab: Creating a multi-stage build in Azure pipeline to deploy a .NET app        160

Chap - 16: Planning the development environment strategy        160

Exploring release strategies        160

Deployment strategies and steps        160

Deployment representations        161

Deployment releases using virtual machines        162

Deployment jobs        163

Summary        163

Implementing deployment slot releases        163

What are deployment slots        164

Demo        164

Summary        164

Implementing load balancer and traffic manager releases        164

Load balancer and traffic manager        164

Demo        164

Summary        165

Feature toggles        165

Feature flag branching        165

Demo        165

Summary        165

Lab: Deploy a node JS app to a deployment slot in Azure DevOps        167

Chap - 17: Designing an Authentication and Authorization Strategy        167

Azure AD Privileged Identity Management(PIM)        167

Why use Privileged Identity Management?        167

What is PIM?        167

What does it do?        168

How does it work?        168

Summary        168

Azure AD conditional access        169

Why use conditional access        169

What is Azure AD conditional access        169

What does it do        169

How it works        169

Summary        169

Implementing multi factor authentication(MFA)        170

What is MFA        170

How it works & Available verification methods        170

Enabling multifactor authentication        170

Demo        170

Summary        170

Working with service principals        170

Using service accounts in code        170

What are Azure service principles        171

How to access resources with service principals        171

Summary        171

Working with managed identities        171

What is managed service identity (MSI)        171

Demo        172

Summary        172

Using service connections        172

What is it        173

Demo        173

Summary        173

Incorporating vaults        173

What are key vaults        173

Azure key vaults        173

Azure key vault using a DevOps pipeline        173

Using HashiCorp Vault with Azure Key vault        173

Demo        173

Summary        173

Lab: Read a secret from an Azure key vault in Azure pipelines        174

Summary        174

Chap - 18: Developing Security and Compliance        177

Understanding dependency scanning        177

Dependencies        177

Type of dependency scanning        177

Security dependency scanning        177

Compliance dependency scanning        177

Aspects of dependency scanning        177

Summary        177

Exploring container dependency scanning        178

Aspects of container scanning        179

Demo        179

Summary        179

Incorporating security into your pipelines        179

Securing applications        179

Continuous security validation process        179

Secure application pipelines        180

Summary        180

Scanning with compliance with WhiteSource Bolt, SonarQube, Dependabot        181

Summary        182

Chap - 19: Designing Governance Enforcement Mechanisms        184

Discovering Azure policy        184

Scenario        184

Azure policy        184

Azure policy Access        184

Demo        184

1. Explore Azure policy        184

2. Explore Azure policy integration with Azure DevOps        185

Summary        185

Understanding container security        185

Azure defender for container registry        185

AKS protection        185

Summary        186

Implementing container registry tasks        186

Azure container registry        186

Tasks (Quick, Automatic, Multi-step)        187

Summary        187

Responding to security incidents        188

Emergency access accounts        188

Best practices        189

What to do after the accounts are configured        189

Demo emergency access account monitoring        189

Summary        189

Summary        189

lAB: Build and Run a Container Using Azure ACR Tasks        191

Chap - 20: Designing and Implementing Logging        191

Discovering logs in Azure        191

What are logs        191

Sources of logs in Azure        191

Log categories        192

Diagnostic log storage locations        192

Demo exploring logs and configuring diagnostics        192

Summary        192

Introducing Azure monitor logs        193

Azure monitor logs        193

Log analytics agent        193

Demo:        193

1. Build and log analytics workspace        193

2. Configure storage retention        194

3. Assemble log analytics queries        194

Summary        194

Controlling who has access to your logs        195

Scenario        195

How many workspaces to deploy        195

Access Modes        195

Access control modes        195

Built-In roles        195

Custom roles table access        195

Demo: configuring access control        197

Summary        197

Crash analytics        197

Crash analytics        197

Visual studio App center diagnostics        198

What happens when a crash occurs?        198

Google firebase crashlytics        198

Demo        198

1. explore visual studio App Center crashes        198

2. explore Google firebase crashlytics        199

Summary        199

Summary        199

Chap - 21: Designing and Implementing Telemetry        200

Introducing distributed tracing        200

Scenario        200

Monolithic application/NTier architecture        200

Microservices/Service-based architecture        201

What do we monitor        201

Distributed Tracing        202

Demo: Application Insights tracing        202

Summary        202

Understanding User Analytics with Application Insight and App Center        202

User analytics        202

Application Insights user analytics        203

Visual studio App Center analytics        203

Export App Center data to Azure        204

Demo        204

1. Explore App Center analytics        204

2. Export data to Azure        204

3. Explore Application Insights User Analytics        204

Summary        204

Understanding User Analytics with TestFlight in Google Analytics.        204

Google Analytics        204

How to start collecting Analytics        205

Demo: Explore Google Analytics        205

Summary        205

Exploring infrastructure performance indicators        206

Performance        206

High-Level performance indicators        206

Example data correlations        207

Low-level performance indicators        207

How to collect helpful data        207

Summary        207

Integrating Slack and teams with metric alerts        208

Action groups        208

Notification types        208

Action types        208

Demo: trigger logic apps to send notifications to Teams and Slack        208

Summary        209

Summary        209

LAB: Subscribe to Azure Pipelines Notifications from Microsoft Teams        209

Chap - 22: Integrating Logging and Monitoring Solutions        211

Monitoring containers        211

Azure monitor container insight        211

Azure Kubernetes service(AKS)        211

AKS Container insight configuration options        211

Prometheus        212

How do Prometheus work        212

Prometheus and Azure monitor integration.        212

Demo:        212

1. Enable container insights using the portal        212

2. Explore container health metrics        213

Summary        213

Integrating monitoring with Dynatrace and New Relic        213

Dynatrace        213

Dynatrace Integration        213

New Relic        213

Other third-party monitoring alternatives        214

Demo        214

1. Azure integration with Dynatrace        214

2. Azure integration with New Relic        214

Summary        214

Monitoring feedback loop        214

Feedback loops        214

Scenario        214

Demo: implement feedback loop using a logic app        214

Summary        215

Summary        215

AZ - 400 DevOps Engineer

The broad range of topic

  1. SRE
  2. DevOps security and compliance
  3. Source control
  4. Azure Pipeline
  1. CI/CD on Azure DevOps
  1. Communication and Collaboration
  2. Monitoring and Logging
  3. Alerting policies

Scenario

Chap -1: Developing an Actionable Alerting Strategy

SRE - Site Reliability Engineering

What is reliability:  

Concepts 

Measuring reliability
What is SRE

The approach was created at Google in 2003 by Benjamin Treynor Sloss, who described it in an interview as, "What happens when you ask a software engineer to do an operations function?"

What:

Why/Goal:

Why do we need SRE

What 

Generally, in traditional environments, reliability is not focused on.

Product managers don't view it as part of their concerns and will often categorize reliability

as a nonfunctional requirement.

issue

The result is that work gets siloed.

Software engineers focus on development and then throw it over to the wall to the operators

who end up supporting an application that they're not very familiar with and then perform inefficient and manual fixes.

Resolve 

So with site reliability engineering, you have engineers working the full stack. Often, production issues are software problems, so the same developers that wrote the code

are also supporting the application, and they can go back and edit the code to increase performance and develop automation to reduce errors and save time.

Key concepts
  1. Feedback
  2. Measuring everything
  3. Alerting
  4. Automation
  5. Small changes
  6. Risk

SRE vs. DevOps

DevOps

SRE

DevOps is more of a culture of a group or a company where the roles of the developer and operators are brought together.

SRE is more of an engineering discipline that uses DevOps principles.

if there's a problem, the operators will bring in a developer to help solve the problem.

if there's a problem, the operators will bring in a developer to help solve the problem.

focus is more on development and deploying faster,

Focus- development → testing → production

Focus- development ← testing ← production

Summary
  1. Reliability can be described in availability, performance, latency and security
  2. SRE takes development practices to solve operations problems
  3. site reliability engineers are effective because they can edit the code across the stack
  4. SLA is the agreement made with the customer on how reliable their system or service will be
  5. SLO defines those goals for the agreement
  6. SLI comes from the actual metrics and data from the system to be used to create goals
  7. SRE focuses on production and then looks back, whereas DevOps focuses on development and deployment to the next stage

Exploring metrics charts and dashboards

Intro to Azure monitoring

General location to gather information from your applications, infrastructure, and Azure resources

For the most part, this information is stored in 2 ways.

  1. Metrics:
  1. Metrics are various pieces of numerical data that describe/measure how something is performing at a certain period of time, as well as what resources it is consuming // performance counters
  2. Data points that describe system performance and the resources consumed at a certain point in time
  3. Examples like CPU, memory, or network traffic.
  1. Logs:
  1. are messages that are generated by certain events in your system.
  2. examples like errors or traces.
Azure Monitor metrics overview

what you can do with metrics?

  1. Visualize 
  1. the data in various charts and graphs using Metrics Explorer.
  2. can save them to a dashboard or use them in a workbook.
  1. Analyze
  1. the data in the Metrics Explorer to see how systems are performing over time or compare it to other resources.
  1. Alert
  1. create alerts based on metrics data
  2. Example: VM reached a certain CPU threshold
  1. Automate
  1. implement autoscaling based on a certain level of traffic.
Demo
  1. Create a chart to view metrics
  2. Add additional metrics and resources
  3. Add charts to dashboards

Summary  

Implementing application Health checks

Scenario

A company using Azure monitors metrics for infrastructure health

Problem is this does not necessarily show the health of their actual applications.

So far, we've been doing manual checks to ensure the application is up.

Need: We are looking for a more automated process

Solution: Application Insights

What is Application Insight

Comes under Azure monitor service

Application Insights is a robust solution in and of itself

What 

Features 

It will give you information about

Availability

With Application Insights, you can configure a URL ping test, and this will send an HTTP request to a specific URL(your website URL) to see if there's a response.

Demo
  1. Configure URL ping test
  2. Configure health alert

Summary

Discovering service and resource health alerts

Azure status

https://status.azure.com/en-ca/status

public-facing website that displays

Things that are out of your control but can affect your resources in Azure.

Service health

Resource health

What: shows you health information about your individual resources.

How: by using signals from other Azure services to perform certain checks.

Demo
  1. Azure status page - https://status.azure.com/en-ca/status
  2. View service health pages and create alerts

Monitor → resource health → add service health alert

  1. View resource health and create alerts
  1. Can filter resource group, resource, future resources
  2. Active resources  

Monitor → resource health → add resource health alert

Summary
  1. Azure status page provides data for all services and regions
  2. Service health page provides data for the services and region you are using
  1. Service health alerts can be configured to notify an action group based on configurable events and conditions
  1. Resource health provides data for individual resources
  1. you can create alerts on specified resources based on certain resource health statuses and conditions

Self-healing alerts

Scenario

What 

Need

Vertical vs horizontal scaling

Vertical scaling

Horizontal scaling

Change the size of the VM

Change the number of VM

Still have 1 VM

Can have multiple VM sharing the load equally

App Service vs. VMSS(Vitual machine scale set)

Horizontal scaling on PaaS(App Service) & IaaS(VMSS)

App service - PaaS

VMSS - IaaS

No access to underlying machine → you just manage the code → worry about code not hardware

Full access to VM

Higher flaxibity and less management // worry about code not hardware

lower flaxibity and higher management // ability to manage VM and have access to environment variables, registry, file system, local policies

Built in load balancing

Require separate load balancer

Auto scaling - scale up

Auto scaling - scale out

Autoscaling process

How:

Demo
  1. Configure autoscale notifications for App service and VMSS

Auto scaling on app service

Auto scaling on VMSS

Summary
  1. Vertical scaling is changing the size,  and horizontal is changing the number of VM
  2. Autoscaling can be configured by matrix or scheduled to a specific time
  3. autoscaling settings can be found in scale out section of a web app
  4. autoscaling settings can be found in the scaling section of a VMSS
  5. Notification can be set in the notify tab once autoscaling is configured

Chap - 2: Designing Failure Prediction Strategy

Introduction

What: analyzing a system with regards to load and failure conditions.

Exploring System load and failure conditions

Everything fail sometimes

What: everything fails whether it is hardware or software it will eventually fail at some point.

Need: goal is to be prepared for any eventuality before being notified by the end-user

Solution: collecting logs and metrics is so important so that we can analyze them and notice patterns to identify even if a failure is likely to happen.

What is failure mode analysis?

What: identify and prevent as many failures as possible

How to plan for failure

Important questions to ask when making your analysis

How can we reduce failure?
Performance Testing

What: important way to understand our application are capable of, so that we can plan to prevent any situation that cannot handle

Types

  1. Load testing: test application can handle normal to heavy load
  1. You would know what the normal load is by gathering metrics and telemetry to understand what the normal numbers are
  1. Stress testing: attempt to overload the system to see the actual upper limits are
  2. Spikes: a best practice is to include a buffer to account for random spikes
Summary
  1. failure mode analysis is a part of the design phase to identify any possible failures that may occur
  2. to plan for failure, understand the whole environment, and uptime expectations(Front and back and dependencies everything)
  3. When it comes to performance testing,  load testing makes sure the application can handle a normal too heavy load
  4. stress testing is used to find the upper limits of what the application can handle

Understanding failure prediction

You cannot prepare for everything
What is predictive maintenance PdM

Different approaches you can take when it comes to maintenance.

How Microsoft used to do PdM

Approach to predict and mitigate host failures

Previous approach

  1. Notification: use machine learning to notify customers of at-risk nodes
  2. Isolate: don’t let any more resources be provisioned on that hardware
  3. Wait and migrate: wait a few days to see if customers stop or redeploy, and if they do not migrate the rest of the workload
  4. Diagnose: what went wrong to see if it can be fixed

How does Microsoft do PdM now

New approach: Project Narya

uses more machine learning to focus more on customer impact

Reduce false positives and downtimes: sometimes the hardware was too damaged to wait or was not as bad as they thought

More signals: continuously grow the number of signals to determine health

More mitigation types: will respond with more types of mitigation and continue to analyze what are the best mitigations

Summary

Understanding baseline metrics

Scenario

Performance testing is hard since each environment has a different load(dev, test, prod)

Hence it’s difficult to do performance testing without proper baseline(what the normal load is?)

Why create baseline

Baseline

How to create baseline

Azure provided tools to create baseline metrics and workloads

  1. Log analytics and Metrics explorer: Create queries and charts to capture and analyze data
  2. Azure monitor insights: provides recommended metrics and dashboards for several services
  1. Click on monitor
  2. Navigate to middle section insights
  3. Insight for services includes VM, storage account, containers, network etc
  4. Click on one of that services and will give you a resource map
  1. Click on the performance tab: to see metrics and chart
  1. Disk performance
  2. CPU Utilization
  3. Available memory
  4. IOPS

To set the baseline

  1. Application Insights: provides recommended metrics and dashboard for an application
  1. ex: Your function is taking too long // normally takes 20 ms to call database, not it’s taking 50 ms

Steps 

        

Demo
  1. Explore Azure monitor insight

See the pictures above for each Azure services

Summary
  1. A baseline can help you identify when a system is not in a healthy state so that alerts and improvements can be implemented
  1. Setup baseline
  2. Create alert
  1. Azure monitor insights provide recommended charts and metrics for Azure resources
  2. Application Insights provides recommended charts and metrics for applications

Discovering Application Insight smart detection and dynamic threshold

Scenario
  1. now using baselines for their performance testing
  2. looking into using that health baseline to create alerts
  3. want alerts to be adaptable to future changes that might alter the baseline(because in future baseline will change, so they want to automatically adjust the alert to the new baseline as things evolve or will they have to review the baselines every quarter or something to decide if they are still relevant)
Dynamic threshold advantages

Advantage over static threshold alerts Machine learning:

  1. Machine learning: is applied to analyze historical data to understand when there are anomalies
  2. less manual work: don’t have to manually figure out what the threshold should be
  3. set it and forget: can be set to apply to any future resources and will continue to analyze data and adapt to changes
Application Insights smart detection
  1. Machine learning: analyze telemetry data to detect anomalies
  2. Built-in: once There is enough time in data to analyze it will be configured automatically
  3. Alerting: provides information based on findings as well as information as to why there might be an issue
Smart detection categories
  1. Failures
  1. failure rates: figure out what the expected number of failures should be
  2. continuous monitoring: alerts in near real-time
  3. alert context: provides information as to why it might have failed.

Needs:

  1. Minimum amount of data and 24 hours to start
  1. Performance 
  1. page responses: if Beach takes too long to load or if operations or responses from dependencies are too slow
  2. daily analysis: sends a notification once a day
  3. alert context: provides information as to why it is running slow

Needs:

  1. The minimum amount of data and 8 days to start
Demo
  1. Create an alert which dynamic thresholds
  1. With high threshold sensitivity, you’ll get more alerts (ex: max-14%, min-4% of VM CPU utilization) - because it’s likely that your CPU utilization will reach 14% more frequently than 17% - hence more alert
  2. With low threshold sensitivity, you’ll get less alert (ex: max-17%, min-2% of VM CPU utilization)
  3. Hight threshold takes the lowest
  1. Create smart detection alerts

Steps:

  1. Navigate to your Application Insight instance
  2. Under investigate, click on smart detection
  3. Click on settings to see details

 

Summary
  1. Dynamic threshold apply machine learning to determine the proper appropriate metrics to be used as a threshold
  2. Smart detection applies machine learning towards application telemetry to notify you of anomalies
  3. Smart detection will continuously monitor failures and provide contextual information as to why it failed
  4. Smart detection will analyze performance once a day to let you know about slow response times

Summary  

Chap - 3: Designing and Implementing Health Check

Deciding which dependencies to set alerts on

What is a dependency?

is one component that relies on another component to perform some function

each dependency exists because each component brings something unique. ex: HTTP calls, database calls, file system calls

Types of dependencies

  1. Internal: which are components that are within the application itself
  2. External: components that are not part of the application but our component that the application uses like third-party services. ex: when an application uses location service and utilizes the Google map API
  3. Dependencies in terms of setting up alerts - Strong vs weak
  1. Strong: strong dependency is a situation where when an application fails and the application doesn’t work at all
  2. Weak: it’s a situation where dependencies fail but the application still runs
Application Insights dependency tracking
  1. Track and monitor: 
  1. helps identify strong dependencies by tracking and monitoring calls.
  2. this tells us if things are failing or not. Once we know if things are failing or not then we can observe how the application reacts to that dependencies
  1. if the application doesn’t work at all with those dependencies failing then this will be a case of a strong dependency
  1. Automatic tracking with .NET/.Net core: tracking is configured by default/automatically if using  .NET/.Net core SDK for Application Insights
  2. Manual dependency tracking: configured using the TrackDependency API
  3. AJAX from webpages: application inside JavaScript SDK will collect AJAX call automatically
Which dependencies are tracked in Application Insights

Automatic

Manual

HTTP and HTTPS calls

Cosmos db with TCP // configur using TrackDependency API

WCF if using HTTP bindings

Radis

SQL calls using SqlClient

Azure storage with Azure storage clients

EventHub client SDK

ServiceBus client SDK

Azure Cosmos DB with HTTP/ HTTPS

Where can I find dependency data

Gives you application focused dependency information

  1. Application Map(Application Insight): Provides handy visualization of all the components in your application
  2. Transaction diagnostics: which you can use to track the transactions as they pass through all the different systems
  3. Browsers: Browser information so you can see Ajax calls from the browsers and users
  4. Log analytics: used to create custom queries against dependency data
Application dependencies on virtual machines

Gives you VM-focused dependency information.

In order to see the dependencies information, you’ll need to install

  1. Agent: dependency agent needs to be installed
  2. Processes: shows dependencies by looking for processes that are running with
  1. connections between the servers that are active
  2. any inbound outbound connection latency
  3. TCP connected ports
  1. Views: from the VM it will show you information just local to that VM, VMSS or from Azure monitor(all components or cluster)
  2. Connection metrics:
  1. response time
  2. how many requests
  3. traffic
  4. links
  5. fail connections
Demo exploring dependencies
  1. Dependencies data in app insight
  1. Click on app insight instance
  2. Under investigate, click on application map
  3. Click on investigate failure and performance to drill down to details

  1. Dependencies data in VM
  1. Under monitor → Insights → VM
  2. Click on Map tab // to see the info on scale set
  3. Use this info to see what happened, when and why

Summary
  1. dependencies are components in an application that rely on each other for specific functions
  2. Dependency tracking is automatically configured with the.net and.net core SDK for Application Insights
  3. Manual dependency tracking can be configured using the track dependency API
  4. The application map provides visualization of application dependencies and correlated data
  5. A virtual machine application dependency map can be found in Azure monitor with system information and connection metrics

Exploring service level objectives SLO

with SLO, Configure our services based on the response times

What makes an SLO?

First, gather

  1. SLI: actual metrics from the system which tell us how the application is performing. Use those metrics to create targets.
  2. Target: which is the upper limit of how we want the system to perform, How reliable and available it is. once you have SLIs and targets, include Timespan
  3. Timespan: The amount of time/time range for SLI to reach to target (acceptable time for the SLI to reach the target limit)

Example: CPU should not exceed 70% over one hour; if so trigger alert

Idea is that we just want to make sure that the system can handle that load.

How is an SLO helpful?

Once SLO is established, how it can help us

  1. Once we have the SLOs in place, then we have an idea of what compute options we should be choosing when configuring our system. // hence make an informed choice on compute options
  2. They also help set the customer expectations
  1. on things like how fast an application will be and how reliable it is.
  2. gives the customer an idea of what the system or application can handle.

Callouts 

  1. The SLO should be re-evaluated from time to time because things change.
  1. for example, if originally, when a company was first starting, there was an SLO where an application can handle 100 SQL transactions per minute,
  2. and now that the company has grown, they need to handle 500 SQL transactions per minute, then those SLOs will be reevaluated, and they would configure their SQL databases accordingly.

SLO’s and response time-outs

Questions: why is my app running so slow?

Answer: number of reasons  

  1. First, it could be a networking issue, where the network requests are taking longer than they really should.
  2. it could be something in the code where the application logic or database queries aren't written as succinctly or optimized to be as efficient as they can be.
  3. This can also be an infrastructure problem, where the infrastructure in place isn't designed to handle the amount of load that the application is bringing in.

So once we have our SLOs, it gives us an idea of what we want our application or system to look like. And then we can adjust any of the things in these categories to meet those expectations.

Demo: Configure Azure SQL to meet SLO‘s

Steps:

  1. You have Azure SQL database. it hasn't been used in the past hour or so.
  2. Click on Compute and Storage to see database was deployed to be a general purpose database
  3. hardware configuration, it's a Gen5, with up to 80 vCores, and up to 408 gigabytes of memory.
  4. we only have 2 vCores provisioned
  5. we have a summary of what we just said, and it shows us a performance graph to let us know if we're optimizing our hardware.
  6. run a workload to see how it handles.
  1. logged into a virtual machine that's connected to the Azure SQL database, and run a workload.
  1. it's creating 20 threads to process queries. And we're going to see how the hardware performs while this workload is running.
  2. navigate down to the Metrics section under Monitoring
  1. choose a CPU percentage metric with your database
  2. change the scope here from 24 hours to let's say the last hour.
  3. And as we can see here, we've reached 100% CPU. // repose time is slow as it’s maxing out 100%
  1. Compute and storage → change vCores to 6
  2. Repeat the step 6,7,8 to see it’s running 20 threads as usual
  1. Cpu percentage hit 54% as compare to 100% previously
Call outs  
  1. Run the database workload(see how many threads are created/running)
  2. Check the metric whether your workload causes the database to reach 100% CPU utilization
  3. If so increase the CPU Core
Summary
  1. An SLO is made up of an SLI, along with limit and timespan
  2. Once the SLO’s published we can choose a computer option to meet those expectations
  3. networking, code and infrastructure can all create situations where the system does not meet the SLO.

Understanding partial health situation

Health monitoring

What? -  How can we design our environment to handle partial health situations?

TODO -

  1. System health: the system is healthy when it is up and performing the functions it is designed for
  2. Alerting: There should be an alerting system in place to notify when something is failing as soon as possible
  3. Traffic light system: Red(unhealthy), yellow(partially healthy), green(healthy) // by dashboard
Health monitoring data

In order to do this, we can utilize things like

  1. User request tracing: which requests from the user has passed or failed and how long did they take
  2. Synthetic user monitoring: emulates the steps that a user would take when they are using an application
  1. this will show you how your application responds to typical user behavior, which can help predict when a system is going to fail, and then you can take precautions to prevent that situation from happening.
  1. Trace and event logs: We also need to make sure that we're capturing trace and event logs.
  1. Trace logs come from the application,
  2. event logs come from the system that's hosting the application.
  1. Logs generated from the application and the hosting infrastructure
  1. Endpoint monitoring: system or application endpoints that are exposed for use as a health check
Telemetry correlation

What 

Why

Application logs best practices

What:  we also want to make sure that our logs are written in a way that's most helpful and actionable to us.

Some best practices are

  1. production log data: log data should be coming from the production environment to get an accurate picture of the production state
  2. Symantec/Structured logging: consistent log structure that helps simplify their consumption and makes them easier to analyze (situation where application generates a text file with all the logs in it and it’s impossible to find anything in the chain file)
  3. log events and service boundaries: using IT to help track transactions through various components(use a correlation ID to track the transaction and find out where and why it fails)
  4. Asynchronous logging:  logging operates independently(because if we use synchronous logging, it can fill up and block the application code)
  5. Separate application logging and auditing: keep application Auditing logs separate so no transactions get dropped
  6. Azure policy: to enforce consistent diagnostic settings
Endpoint health monitoring

What

Examples

  1. response code:  looks to see if there is a 200 response indicating there are no errors
  2. response content: analyze response content to determine if there are parts of the page that are failing even if you have 200 responses
  3. response time: Measure how long it takes to get a response
  4. external components: checks third-party and external components like CDN
  5. certificates: check to see if any SSL certificates are expiring
  6. DNS lookup: make sure DNS lookup is configured correctly and that there are no missed directs
Summary
  1. The system is considered healthy when it is up and running and performing the function that it was designed to do
  2. when monitoring is held it should be clear what the failure is happening
  3. telemetry correlation takes application in system event logs into account to provide a full picture across the stack
  4. Application logs should be consistently structured, easy to analyze, and traceable across service boundaries
  5. Endpoint health monitoring can be used on multiple endpoints to determine health and partial health status

Improving recovery time

Why do we need a recovery plan

Why do we need to make sure that we have a Disaster Recovery plan?

What are the things that can happen that can affect our business continuity?

Recovery situation includes

  1. Ransomware: type of malicious software that's designed to block access to your system until you pay them a certain amount of money.
  2. Data corruption or deletion:
  1. VM was doing some updates and it crashed, and the data on that machine got corrupted,
  2. or maybe somebody accidentally deleted something from a database or a storage account, and they weren't able to recover from it.
  1. Outages
  1. Networking, DNS issues, natural disaster
  1. Compliance
  1. Organization that you're working for requires you to have a business continuity plan to be compliant with their security policies.
High availability(HA) Vs disaster recovery(DR)

HA

DR

Goal is to keep the application up and running in case of a local failure

goal is to make sure that the application can be recovered in an alternate site in a case of a regional failure // failover to secondary region

failover to secondary region against planned(planned outages) - we try best to prevent data loss

unplanned events(natural disaster) - need to determine howmuch data we are willing to lose

Recovery Point Objective(RPO) Vs  Recovery Time Objective(RTO)

What:  

RPO

RTO

In case of an outage, how much data are you willing to lose

In case of an outage howlong can you afford to take to get your system back up and running // this is the measurement that you would use to determine how long your system could be unavailable.

EX: company is willing to lose 30 mins of data loss

EX: we want our system back up and running within an hour.

Business continuity strategies

Strategies we can employ to make sure that we meet our RPO and RTO?

First of all, we need to ensure that we don't just protect the application because there might be dependencies in your environment that are just as important, which we refer to as strong dependencies meaning that without these dependencies, your application can't run.

And it's also important to remember that different situations require different strategies.

  1. Redeploy from scratch:
  1. incase of an outage  
  2. for a noncritical system that you don't need a guaranteed RTO because using this strategy would take the highest Recovery Time Objective(RTO) because you're starting from scratch.
  1. Restore from backup
  1. Take regular backups(of various parts of the system like the databases, the files, the virtual machines) and restore the system from backups.
  2. So when outage, you would just restore the components from the most recent backup, and depending on the Recovery Point Objective, how much data you're willing to lose, that will determine how often you take those backups. // Meaning, the more frequently you take backups means a lower RTO.
  1. Cold site
  1. this is where you keep some of the core components of a system deployed in a Disaster Recovery region in case there's an outage.
  2. Then you have the rest of the components deployed using automation scripts.
  1. Warm site
  1. active passive or standby
  2. this is where you have a scaled down version with the minimum required components needed to run deployed in a DR region, but just sitting there and waiting in case of an outage, meaning that there's no production traffic being sent to this DR location.
  3. this would be used in a case where a system is not designed to be spread across multiple regions.
  1. The RTO would be the time it takes to turn on any of the components if they're off or how long it takes to switch traffic to this second location.
  1. Hot site
  1. active/active, or hot spare, or multi-site
  2. this is where you have a full environment running across multiple regions with traffic being split to both of those regions.

RTO improvement options

So when trying to figure out what option you should use to improve your Recovery Time Objective,

Azure services that help reduce RTO
  1. Azure Site Recovery:
  2. Azure front door
  3. Azure traffic manager

Summary
  1. High availability focus on local failure
  2. Disaster recovery focuses on regional failure
  3. recovery point objective RPO quantifies acceptable data loss
  4. recovery time objective RTO determines how long a system can be unavailable
  5. as we move down this list of DR & HA strategies, we reduce the RTO but the cost of the solution increases

Exploring computer resource health checks

App service Health checks

Azure App Service has a built-in health check where it routes traffic only to healthy instances.

in order to configure this, you need to present a path to verify the health. this can be something like

  1. Endpoint Check:
  1. If the specified path returns a status code of 2XX within 60 seconds it is healthy. this could be an endpoint of database or application itself.
  2. if a response is longer than 60 seconds and returns a 500 status code then it’s deemed unhealthy
  1. it will ping the instance twice and remove it after two unsuccessful pings
  1. Reboot after removal: after removal the instance will continue to ping and then reboot
  2. Replace: if the instance remains unhealthy after one hour it will be replaced with a healthy instance
Customize Web App health checks

How?

VMSS Health extension

What:  this let you know if any of the VMs in the scale set are unhealthy,

How: and it does this by checking an endpoint to determine its health.

Container health check types

Kubernetes can automatically restart unhealthy containers, but by default, Kubernetes will only consider the container to be unhealthy if the container process stops.

And this is where liveness probes come in.

  1. Liveness
  1. customize how to determine if the container is healthy
  2. runs continuously on a schedule
  1. Startup
  1. checks held in container is starting up
  1. Use case : legacy app that takes a long time to startup
  1. no support by an ACI. only in AKS
  1. Readiness
  1. checks when a container is ready to accept request as it starts up
  2. prevent traffic to pods that are not yet ready

Liveness Check Example

https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ 

Type: LIVENESS

Method: exec

livenessProbe:
   
exec:
     
command:
      - cat
      - /tmp/healthy
    initialDelaySeconds: 5
    periodSeconds: 5

Startup Check Example

Type: startup

Method: HTTPGET

startupProbe:
httpGet:
  path: /healthz
  port: liveness-port
failureThreshold: 30
periodSeconds: 10

Readiness Check example

readinessProbe:
    tcpSocket:
      port: 8080
    initialDelaySeconds: 5
    periodSeconds: 10

Summary
  1. App service Web Apps have a built in health check that can be configured to check a specified in point for health status
  2. web apps are healthy if the response returns eight 200 response code with 60 seconds
  3. an application health extension can be deployed to check the health of VMs in a virtual machine scale set
  4. You can determine container health by executing a command, sending an http request, and attempting to open a TCP socket
  5. container liveness probes allow you to configure custom health checks that run continuously
  6. container startup probs provide health checks only when the container start up
  7. container readiness probes will let you know when the container is ready to receive requests

Summary

Chap - 4: Developing a modern Source Control Strategy

First step of CI/CD process of source control

Introduction to source control

What is source control
  1. Also known as source repository/version control (Central source of truth for group code base)
  2. allows multiple developers to collaborate on code and track changes (critical for any multi developer project)
  3. example Azure repos, GitHub, BitBucket
Source control types
  1. Git
  1. distributed/decentralized
  2. the deafult preferred option
  3. Each developer has a copy of the repo on their local machine
  1. includes all branch and history information
  1. Each developer checks in the local portion of the code and changes are merged in a central repository
  1. Team Foundation version control - TFVC
  1. Centralized /Client-Server
  2. the non-default option
  3. developers checkout the only version of each file on local machines(instead of an entire copy of code base)
  4. checked in code is then pushed to everyone else
Which one to use?
Summary
  1. What is source control? the central source of truth for group development
  2. source control types: Git and TFVC
  3. primary focus on GIT both inside and outside of Azure repos

Exploring Azure repos

Azure repos at a glance
  1. Exist inside of Azure DevOps organization
  2. Project level
  3. Supports Git and TFVS
  4. An optional component for Azure pipelines
  1. can use external referrals in pipelines
Setting up Azure Repos
  1. all options involve getting code from somewhere else into Azure repos(Azure repo then becomes the source of truth)
Import options
  1. set up empty repo from scratch
  2. clone existing repo into Azure repo(GitHub, another Azure repo)
  3. push local code base into Azure repo

Supported GIT features
  1. branching methods
  2. history
  3. tagging
  4. pull request
  5. and much more // if it works in Git, it works with Azure repo
Summary
  1. Azure repo overview: managed repositories inside Azure DevOps organization
  2. import options: start from scratch, import external repo, push local code base

Azure Repos demo and Git workflow

  1. clone GitHub repo to Azure repo
  1. Import any public Git repo into Azure repo
  1. clone Azure repo to local environment and authenticate to Azure repos
  1. Clone repo
  1. Generate Git credentials // copy the password
  2. Clone in VS Code
  1. Enter password from step
  1. Update local code copy, and push/pull new changes to/from Azure repos

Repository sharing with submodule

Share repository using submodules

What are submodules

scenario

  1. challenge: Need to incorporate resources from a different GIT project in your current repo
  1. Examples: third-party library used in your projects
  2. need to treat external resources as separate entities yet seamlessly included within your project
  1. Solution:  submodules
  1. not limited to Azure repos, core GIT feature - with an Azure twist

Callout 

How submodule works
  1. add the external repo as a submodule to your repo
  2. when cloning a project with a submodule into your local directories extra steps are required
  1. initialize an update submodule

Submodules in Azure DevOps
  1. requirements to include in build pipelines
  1. Unauthenticated - i.e, publicly available
  2. Authenticated within your main repository account
  1. same GitHub organization, Azure organization, etc
  2. same account to access the primary repo must also be the same one to access the submodule repository
  3. submodules must be registered via http - not Ssh
Demo: adding submodule to repo
  1. Add a submodule to our locally cloned repo

        

  1. push updates to Azure repos and view the results
  1. Once you push changes the file turns to blue and we have S next to it, notifying that its submodule
  2. if we were to clone and work with this repository onto a new machine, or even to our existing environment,
  1. we would need to manually update and initialize those submodules on the machine using the submodules init and update commands that we talked about earlier in this lesson.
Summary 
  1. what are submodules? - nested resources posted from external repos
  2. how do you use submodules - adding new | initializing clone
  3. authentication with Azure pipelines: unauthenticated or authenticated with the same organization and rates as primary repository

Summary

lab: authenticate to Azure repose using an authentication token

Objectives:

Steps

  1. Create a new repo from Azure DevOps
  2. From Repos → Files → Initialize master ranch with README  and gitignore
  1. Add a gitignore: visual studio // will create new repo
  1. Create personal access tokens
  1. Create new token
  2. Set expiration
  3. Select scope
  1. Copy token
  2. Clone repo from Azure repo
  3. In your local env: use the cloned URL
  1. Enter password/PAT

Chap - 5: Planning and implementing branching strategies for the source code

Configure branches

What is a branch

branch is a way in order for you to isolate code, work on it, and bring it back to the main source code.

Branch management
  1. Branch policies
  1. Initial safeguard
  2. Require a minimum number of reviewers: require approval from a specified number of viewers on a pull requests
  3. Check for linked work items: encourage traceability by checking for linked work items on pull requests
  4. Check for comment resolution: check to see that all comments have resolved on pull requests
  5. Limit merge types: Control branch history by limiting the available types of Merge when pull requests are completed
  1. Branch restrictions
  1. Advanced safeguard
  2. Build validation: Validate code by pre-merging and building pull request changes
  3. Status checks: requires other services to post successful statuses to complete pull requests
  4. Automatically included reviewers: designate code reviewers to automatically include when pull request change certain areas of code(manual approvals)
  5. Restrict who can push to the branch: use the security permission to allow only certain collaborators the ability to push to the branch
  1. Branch protections
  1. Minimize catastrophic actions
  2. prevent deletion: accidentally or intentionally
  3. prevent overwriting: the branch commit history with a force push
Summary
  1. branch copy of a codeline helping development team work together
  2. branches are managed by policies, restriction and protections
  3. initial safeguards:  reviewers, work items, comments, merge types
  4. Advance safeguards: build validation, status checks, manual reviewers, push restrictions
  5. catastrophic protection: prevent deletion, prevent overwriting commit history

Discovering Branch Strategies

Branch strategies

Why do you need branch strategy

  1. Optimize - productivity
  2. Enable - parallel development
  3. Plan - set of structured release
  4. Pave - Promotion parts or software changes through production
  5. Tackle - Delivered changes quickly
  6. Support - multiple version of software and patches

Summary

Pull request workflow

What is pull request
Goals
  1. Reduce bug introduction: documentation in full transparency enable team to verify changes before merging
  2. Encourage communication: feedback and voting in a collaborative atmosphere even in early development
  3. Speed product development: faster and more concise process ensures speedy and accurate reviews
What’s in the pull request
  1. what: an explanation of the changes that you made (context)
  2. why: The business or technical goal of the changes (the bigger picture)
  3. how: design decisions and rationale on code changes approaches (reasoning)
  4. tests: verification of test performed and all results (verification)
  5. references: work items, screenshots, links, additional downloads, or documentation (validation)
  6. rest: challenges, improvements, optimizations, budget requirements (other)
Pull request workflow
  1. Assign request
  2. Review code
  1. If good: approve the request: merge
  2. If no:  Request change
Summary
  1. pull requests encourage collaboration and verification of valid code
  2. they contain the what, why, and how of the code changes
  3. they are used on a branch prior to merging

Code reviews

How can you make code reviews efficient
  1. Code review assignments
  2. Schedule reminders
  3. Pull analytics

Demo

Objectives: review the following in GitHub

  1. Code review assignment
  2. Schedule reminders
  3. Pull analytics: pay feature in GitHub
Summary

Static code analysis

Static

Dynamic

If you are reviewing code as it sits

Code that is currently executing/running

Guidelines for effective code review
  1. Size limit
  1. less than 400 lines of code
  2. less than 60 minutes of review at a time
  1. Annotations
  1. authors should guide reviewers
  2. provide more in-depth context
  1. Checklists
  1. People make mistakes the same ones a lot
Code quality tools

Code scanning tools that help you weed out common issues like

  1. Coding errors
  2. Security vulnerabilities
  3. Find triage prioritize
Demo

Review the following and GitHub

  1. GitHub marketplace
  2. Code review
  3. Code quality tools: DeepSource(free)
  1. for pull request, you can use an application to automatically scan in addition to having a review or check the static code and dynamic state
Summary
  1. code analysis approach combination of both static and dynamic
  2. Integrate code scanning tools to automatically test quality and security
  3. use annotations and checklists to speed up code reviews and analysis

Useful requests with work items

The importance of relating work items
Demo

Objectives: review the following in GitHub

  1. pull request guidelines
  2. enforcing work item correlation
  1. Setting → repo → Branch policies → ON Checked for linked work items
Summary
  1. Use # to add work item references in a pull request
  2. It’s recommended to always correlate work items with pull requests
  3. it’s possible to close a work item with completed pull request

Lab:  Configure branch policies in Azure Repos

  1. Import GitHub repo to your local environment OR Write your code in your local environment
  2. Add the remote location of Azure repos
  3. Push and existing repo from the command line to Azure repo
  1. Copy command
  2. Git Push
  1. On Azure repo
  1. Setting → repo → Branch policies → ON require a minimum number of reviewers
  1. allow requesters to approve their own changes
  1. Setting → repo → Branch policies → ON Checked for linked work items

Summary

Chap - 6: Configuring Repositories

Using Git tags to organize your repository

What are Git tags, and why do we care?

Git tags are a built-in Git feature, which allows you to

  1. mark a specific point in a repository's history.
  1. notate specified versions - v1.1, v1.2, etc
  2. can add notes(annotations) on commit details

tags = special name applied to a commit

How to create tag

  1. Web portal
  1. Local 
Tag types and how they work

Lightweight

Annotated

No notes, just a tag name

Attach a note on tag details

Simply a pointer to specific

Stored as a full object in Git database

Ex: git tag v1.2

Ex: Git tag -a v1.2 -m “Updated html content”

Demo + Tags in Azure repos
  1. take over local repository and push to Azure repos
  1. Add and commit changes
  2. Tag your commit by git tag -a v1.2 -m “Updated html content”
  1. Check tag by // git tag
  1. Git push
  1. view tagging in Azure repos, and apply the tag via the web portal
Summary
  1. Git tags: special notes on importance of specified commits
  2. Tag types: lightweight, annotated
  3. Azure repos: annotated tags only
  4. Working with remote repositories: separate tag push required

Handling large repositories

Challenges of Large repos
  1. Challenge: Git repos are not bulk file storage
  1. small footprint intended
  2. some file types should not be used in repos
  3. however some large binaries must be included
  1. Why is Git footprint size important?
  1. cloning repo copies full history of all final versions
  2. frequently updated large files = serious performance issues

Solution

  1. use best practices to avoid size bloat
  1. know what not to include
  2. use gitignore file
  1. for unavoidable large files use git LFS
  2. clean up accumulated clutter with git gc
Working with Git large file storage LFS
  1. large file management built into Git
  1. Open source extension(separately installed)
  2. supported by popular remote repos(GitHub, Azure repos)
  1. Tagged large files stored by remote repo but as a placeholder in actual source code

How Git LFS works

  1. Install Git LFS for your OS
  2. Initiate LFS on your local environment // git lfs install
  3. Tag files to be added to LFS before committing them // git lfs track “*.psd”
  1. this result in a .gitattributes file
  1. Commit as usual. the remote repo will store tag to file separately
  1. text file will be marked in line with source code
Best practices for working with large files

what type of file you don’t want to include in LFS

Clean up with git gc

Summary
  1. Avoid large file bloat: large files in history drag down performance
  2. Git LFS: Open source large file management | remote repo markers
  3. Best practices: keep unnecessarily large files out of source code - alternative solutions
  4. git gc - garbage collection- know flag to keep/prune loose files

Exploring repository permissions

Branch permissions in Azure repos
  1. Branch level permission access
  1. provides users different access to different branches
  2. by default inherited from organization project level roles
  3. provides access to main branch but not sub brand or vice versa
How branch permissions work

Branch locks

Demo: working with branch permissions/locks
  1. View new feature branch permissions
  1. view inherited permissions
  2. set new one
  3. explore branch locks
Summary
  1. Ability to manage branch level permission in Azure repos
  2. Inheritance: pull from organization/project groups | can add/override inherited roles
  3. Branch locks: lock a branch in read-only mode for pull requests.

Removing repository data

Challenges of removing Git Data

unwanted files in git

scenario: you mistakenly commit and/or push files that you should not included

problem: deleted files from gnu commit still exist in the repo’s history

Solution: remove bad comments before or after pushing to a remote repo

Unwanted file states

Local commit but not yet pushed

Pushed to remote repo

Bad comment on local environment but not yet post to remote repo

Bad commit post to remote repo

solution: remove/amend bad local commit

solution: delete remote commit

alternatively remove:  unwanted file history with caveats

  1. removing/amending local commit before push
  1. delete unwanted file
  2. remove file from git tree/index // git rm –cached <filename>
  3. delete or amend previous commit depending on what other data changed
  1. Entirely delete commit - git reset HEAD^
  2. Amend commit - git commit –amend -m “comment”
  1. Remove already pushed commit
  1. Reset back to last good commit // git reset –hard #commitSHA
  2. Force push to remove comments past the last good one // git push —force
  3. all branch commits past the recent one will be deleted.
File removal scenario

Remove unwanted files from past commit’s history

  1. there are multiple tools to remove files from past history some are official other community created
  1. git filter-branch: built-in method
  2. git filter-repo: officially recommended community solution
  3. BFG repo cleaner
  1. even after successful removal you can still view file history in the Azure repo’s web portal // in GitHub you’ll have to reach out support to see deleted file
Demo: Removing Unwanted files from Azure repo
  1. create and commit password file but remove before pushing
  1. add and commit changes
  2. delete unwanted file
  3. remove file from git tree // git rm —cached <filename>
  4. entirely delete commit // git reset HEAD^
  1. push bad commit then delete commit from Azure repos
  1. add, commit, push commit
  2. roll back to previous good commit
  1. get previous commit SHA // git log —oneline
  2. git reset —hard SHA-ID
  1. git push —force
Summary
  1. know removal methods for unwanted files
  2. removal methods:
  1. amend commit before pushing
  2. remove unwanted commit from remote repo
  3. remove unwanted files from history
  1. demo: fixing bad commits before and after pushing to remote repo

Recovering repository data

what do you need to do when you accidentally remove data from your repository

Recovery scenarios

mistakes happen

Scenario: You accidentally may delete something and you need to know how to get that data back.

what: Need to know how to recover or ‘rewind time’ in the above scenario

Revert to previous commit

scenario: commits contains errors - need to roll back

  1. reset back to last good commit and resume development from there // git reset —hard #commitSHA
  2. coordinate with development team members to merge changes to reverted code
  1. known as rebase
Restore deleted branch from Azure repos
  1. in Azure repos, from the branches view search for the deleted branch
  1. branches —> search branch name(menu)
  2. at bottom you’ll see deleted branch
  1. from the deleted branches search, click restore branch
  1. from context menu click on restore branch
Restore deleted Azure repository
  1. despite warning repo is in a soft delete state and can be restored
  2. Restore via an authenticated API call
Demo: recover deleted branch
Summary
  1. Be familiar with multiple repo recovery scenarios/resolutions
  1. Revert to previous commit
  2. Restore deleted branch
  3. Restore deleted Azure repo

Summary

Chap - 7: Integrating source control with tools

Connecting to GitHub using Azure active directory

What: how to connect a GitHub Enterprise account to Azure Active Directory using single sign-on.

Link: https://docs.microsoft.com/en-us/Azure/active-directory/saas-apps/github-enterprise-managed-user-tutorial 

Advantage of AAD integration
  1. Why this matters
  1. by default GitHub and AAD identifies are separately maintained // different passwords for different applications
  2. however we can integrate GitHub identities with AAD using single sign-on(SSO)
  1. advantages of GitHub/AAD integration
  1. manage GitHub account from a central location Azure active directories
Requirements for connecting to AAD
  1. must have GitHub Enterprise cloud organization from GitHub side in order for SSO to work
  1. GitHub team plan unable to use SSO // won’t work on team plan
  1. permissions
  1. GitHub: administrator
  2. Azure: create SSO - Global admin, cloud application administrator, application administrator
Azure AD SSO configuration
  1. add GitHub in enterprise application
  2. Configure SAML SSO configuration with GitHub enterprise account
  1. like to GitHub Enterprise organization: GitHub org identifier, reply URL, sign on URL
  2. set User attribute: don’t need to edit default settings
  3. download base64 signing certificate for GitHub side
  1. add AAD user to GitHub SSO
GitHub enterprise configuration
  1. enable SAML authentication
  2. configure link to AaD tenant
  1. Login URL —> sign on URL
  2. AAD identifier —> issuer
  3. Open and copy/paste sign in certificate from AAD
  4. set signature digest method to RSA-SHA256/SHA256
Summary
  1. Configure SSO to manage GitHub enterprise users from a single AAD location
  2. Requirements: GitHub enterprise cloud
  3. high-level process: Azure AD and GitHub linking steps

Introduction to GitOps

automation process

What is GitOps
  1. DevOps approach to deploy infrastructure as opposed to deploying applications
  1. automation pipelines for deployment
  2. tracking of updates/changes with source control
  3. Git = Single source of truth for infrastructure version control
  1. GitOps management example
  1. kubernetes manifests
  2. infrastructure as code: terraform, ARM Template
Sample GitOps workflow

  1. flux CD: tracks the infrastructure changes and deployed to Kubernetes environment

  1. repo: stores kubernetes manifests (deployment, replica)

Why:  

we would instead be using kubectl commands, like kubectl apply, to mainly take container images, and apply it to our Kubernetes cluster.

Exam perspective

Understand scenarios that call for GitOps

Summary
  1. Understand role off GitOps for automated infrastructure management
  2. Role of source control: host infrastructure manifests/changes automatically deployed

Introduction to ChatOps

What is ChatOps

All about automation

  1. ChatOps is automating event communication to collaboration tools
  1. new commit pushed to repo, new pull request
  2. build pipeline success/failure
  1. integrate collaboration tool with Azure DevOps
  1. ongoing topic throughout course
How to connect Chat apps to Azure DevOps

Connect various collaboration or chat applications with Azure DevOps working with both portion control and pipeline

  1. depends on the application
  1. some apps support native integration(MS Teams)
  1. generally, service hooks publish events to subscriptions (applications)

service hook: feature within Azure DevOps that is able to published events that take place inside of your pipeline to different subscribed applications

  1. configure service hope to publish requested events to application

Demo
  1. explore service hooks/webhooks in DevOps project

steps

  1. Azure DevOps —> project settlings
  2. general —> service hooks
  3. create subscription
  4. select your service

        

Summary
  1. understand the importance of ChatOps for DevOps event communication
  2. general ChatOps Configuration: Service hooks publish event data to subscribed applications

Incorporating Changelogs

How to work with logs generated about what happened in source repo within a DevOps pipeline

What is GIT Changelogs?
  1. Record of changes(commits) in a project lifetime
  1. who did what and when
  1. why do we care about Changelogs
  1. keep running list of changes/updates
  2. useful for teams working on a single project
Manually creating/viewing Changelogs
  1. git log command - git log
  2. options to clean log output
  1. one line summaries - git log —online
  2. remove commit ID, custom elements - git log —pretty=“- %s”
Automation options
  1. third party applications
  1. GitHub Changelog generator Auto Changelog
  1. IDE Plugin
  1. visual studio Changelog plugin
  1. pipeline plugins
  1. Jenkins has a Changelog plugin
Demo viewing Changelogs via command line
  1. view and create Git Changelog
  1. View formatting options
  2. Export to text file

steps 

  1. git log to see common logs
  2. concise logs // git log —oneline
  3. customize output - input dash as a header —> git log —pretty=“- %s”
  4. Export to text file // git log —pretty=“- %s” > txt.file
Summary
  1. Git Changelog provides a history of project updates
  2. IDE & pipeline plugins
  3. Manually viewing/creating Changelogs with formatting options

Summary

Chap - 8: Implementing a build strategy

Pipelines: automating build and release of application

Getting started with Azure pipelines

Pipeline

Key

What are Azure pipelines

Build and Release pipeline

Continuous integration

Continuous delivery

Importance of automation

Scenario: life of kubernetes container deployment

Task:

Issue

Steps:

Danger of repetitive, manual actions

SRE perspective

Pipeline basic/structure/trigger

Azure pipeline

pipeline = automated sequence of steps to build/test/release code

pipeline structure

stages —> jobs —> steps

Stage = can have multiple stages

Jobs 

Steps

Trigger

Summary
  1. Automate the application building and deployment process
  2. with steps defined in YAML files
  3. organized by stages → jobs → steps
  4. get it out by agents(managed VMs)
  5. and is automatically started based on defined triggers

Azure pipeline demo

  1. Deploy python flask application using Azure app service
  1. Build, Package and deploy it to AppService

Steps 

  1. On Azure DevOps, click on pipelines
  2. Create a new pipeline
  3. Select your source control → repo
  4. Configure your pipeline: python to Linux web app on Azure
  1. Connect DevOps Project to Azure subscription
  2. Web app name
  1. YAML will be created automatically
  1. Trigger: master
  2. Web app name:
  3. Agent VM: Ubuntu
  4. Environment name
  5. Project root folder
  6. Python version

YAML pipelines contain

  1. 2 stages
  1. Build
  2. Deploy
  1. 1 job per each stages with multiple steps
  1. Pool: designates which agent we will be used to build and deploy application for us - microsoft hosted agent - ubuntu latest

Integrate source control with Azure DevOps pipelines

Source control options

Code can be live at

Connect this souce control to pipeline to automatically start building and deploying code into production

GitHub, Subversion

Connect GitHub repo to Azure pipeline 

  1. Preferred method: install/configure Azure pipelines app and associate it with your GitHub repo(in GitHub repo)
  2. Authenticate via OAuth or personal access token(PAT)

Connect Subversion repo to Azure pipeline 

Configure access with service connection

Configure Subversion repo URL/Authentication

Demo
  1. Connect Azure pipeline to GitHub repo
  1. On Azure pipeline → create a new pipeline
  2. Where is your code → GitHub

Options 1: OAuth

Option 2: marketplace app authentication method

  1. Click on marketplace
  2. Search Azure Pipelines and install it
  3. Choose repo will setup with Azure pipeline
  1. All repo
  2. Single repo
  1. Click install
  2. Sign in to your Azure DevOps account
  3. Select your org and project
  4. On GitHub, authorize Azure pipeline
  1. Explore service connection:
  1. to connect things(products) to pipeline which are outside if your Azure DevOps Org
  1. Explore source control connection option  
Summary
  1. understand source control connection options depending on repo location
  2. GitHub connection options: configure GitHub app | OAuth/PAT Authentication
  3. subversion connection option: configure service connection

Understanding build agents

Role of agent

Pipeline: act as the automation engine to carry out a series of manual repetitive steps on our behalf so we don't have to.

How Pipeline works

Agent 

Microsoft and self-hosted agent

Parallel jobs

What - Parallel jobs are simply how many agents are allowed to run in your Azure pipelines environment or your organization at the exact same time.

MS Hosted agent charges - $40 p/month

Self-hosted agent charges - $15 p/month

Demo
  1. See agent billing section on org level

Exploring self hosted build agents

Self-hosted agent scenario

Why use self-hosted agents

  1. Hardware customization
  1. Use self-hosted agents - If you need more processing power, storage, GPU
  2. Because MS hosted agents are limited to
  1. they come in the standard DS2_v2 VM size
  1. which comes as two virtual CPU and 7 gigabytes of memory
  2. limited to 10 gigabytes of storage
  3. no GPU option
  1. Pipeline builds using hybrid non-Azure resources
  2. maintain machine level configuration/cache
  1. desire to not have a clean slate between your builds but instead to keep the same configuration or the same hardware cache between individual builds.
  1. more control over software configuration
Self-hosted agent communication process
  1. Install self-hosted agent
  1. install your self-hosted agent on whatever machine you want that pipeline to run on(this could be an on-premises machine, an Azure virtual machine, or  really anywhere else)
  1. register and authenticate agent
  1. add to agent pool
  2. agent will watch agent pool for new jobs
  1. Pipeline jobs sent to agent pool
  1. Job assigned to agent in pool
Agent pools

Demo

Assign job to agent pool

  1. install and configure self hosted agent on a Windows virtual machine in Azure
  1. create personal access token for agent authentication
  1. from Azure DevOps org, click on User settings —> click on personal access tokens
  2. new token
  1. name: self hosted agent
  2. org: if more than one
  3. scopes
  4. agent pool: read & manage
  5. create
  6. copy/paste token somewhere safe
  1. install and configure self hosted agent on windows VM
  1. org setting —> pipelines —> agent pool
  1. Azure pipelines: MS hosted agents
  2. default
  1. click on default
  1. new agent (windows, MacOs, Linux)
  2. download agent
  3. follow steps
  1. post install, view agents in agent Pool
Summary
  1. Know scenarios calling for self hosted agent
  2. agent registration process: configure agent and assign to agent pool
  3. YAML Schema: assign job to self hosted agent pool vs ‘vmImage’

Using build trigger rules

Trigger types

Tigger = automatically start pipeline in response to an event

Where: trigger defines in YAML

Trigger type

  1. CI Trigger
  1. When: you update repo or branch of that repo
  2. Example:
  1. Specify which branch to watch for update
  2. Optional inclusions/exclusions: more granular with what branch to include/exclude
  1. Wildcard // If you have sub-folder/tree of branch
  2. Exclude branches in wildcard grouping
  3. Tags to included in your trigger

        

trigger:
 branches:
   include:
   - master # Specify which branch to watch for update to run pipeline
   - releases/* # If you have sub-folder/tree of branch

    - refs/tags/{tagname}
   exclude:
   - releases/old*

  1. Schedule trigger
  1. When: run pipeline at a specified time
  2. Example: run pipeline every night whether or not your repo is updated
  1. Scenario: pipeline run weekly sunday
  2. Trigger independent of repo
  3. Define schedule in cron format
  4. Can choose to run only if targeted repo has changed: if your repo has updated since your last schedule trigger

schedules:

- cron: "0 12 * * 0"
 displayName: Weekly Sunday build
 branches:
   Include: new-feature
 always:
true  # whether to always run the pipeline or only if there have been source code changes since the last successful scheduled run. The default is false.

  1. Pipeline trigger
  1. When: pipeline runs when another pipeline runs first
  2. Scenario:  When upstream component (library) changes downstream dependencies must be rebuild
  1. include:
  1. triggering pipeline and pipeline resource
  2. trigger filter: trigger pipeline when any version of the source pipeline completes
  3. Optional: branch/tag/stage filters for referenced pipeline
  4. Optional: pipeline project if in a separate DevOpsproject

resources:
 pipelines:
 - pipeline: upstream-lib
# Name of the pipeline resource.
   
source: upstream-lib-ci # The name of the pipeline referenced by this pipeline resource.
   project: FabrikamProject
# Required only if the source pipeline is in another project
   trigger:
true # Run app-ci pipeline when any run of security-lib-ci completes

  1. Pull Request trigger
  1. WHEN: Run pipeline on pull request
  2. scenario: validate/test code upon pull request (This pull request can run a new pipeline to test our code to make sure it works)
  3. configuration depends on repo location
  1. Azure repos: configure in branch policy (not in YAML)
  2. if not in Azure repo then specified this trigger in the YAML pipeline by example shown below

        

pr:
- main
- releases/*

Summary
  1. no the main trigger types: CI/scheduled/pipeline/pull request
  2. filter methods: wildcard/inclusion/exclusion/tags
  3. configuration method: pipeline YAML file, except for Azure Repo pull request(branch policy)

Incorporating multiple builds

Multiple Build scenario

When: Need to run multiple build/jobs in different environments

Scenarios: where you need to run multiple builds/jobs within a single pipeline with different environments

  1. run unit tests against different versions of python(python 2.7, 3.5, 3.6, 3.7)
  2. test builds against multiple OS(Windows, Mac, Linux)

How

  1. Create multiple pipelines
  2. multiple jobs inside of a pipeline
  3. Best way: duplicate the same job with slightly different inputs in the same pipeline

Solution

Strategy →  Matrix Schema

Strategy: Strategies for duplicating a job

Matrix:  generates copies of a job each with different input

Example:

  1. Run pipeline, testing multiple Python version
  2. Run pipeline, testing against multiple OS
Demo
  1. Run pipeline, testing multiple Python version

  1. Run pipeline, testing against multiple OS

strategy:
 matrix:
   linux:
     imageName:
'ubuntu-latest'
   mac:
     imageName:
'macOS-latest'
   windows:
     imageName:
'windows-latest'

pool:
 vmImage: $(imageName)

steps:
- task: NodeTool@0
 inputs:
   versionSpec:
'8.x'

- script: |
   npm install
   npm
test 

Summary
  1. know how to corporate multiple input builds in a single pipeline
  2. pipeline YAML schema: strategy providing matrix variables of multiple inputs
  3. steps of configuration: call on matrix variable to create duplicate jobs with different inputs

Exploring containerized agents

What:

Why run a pipeline job in a container

Why exactly would we want to run a pipeline job in a container to begin with?

Why:

  1. Isolate from host - when you need to isolate your build environment from the underlying host
  1. use specific versions of tools and dependencies: need to use different versions of tools, operating systems, and dependencies than those that exist on the host operating system itself.

Links

https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/docker?view=azure-devops 

https://docs.microsoft.com/en-us/learn/modules/host-build-agent/ 

3 scenarios 

Microsoft hosted agent configuration

What: Microsoft is going to provide the agent for you. And inside of that Microsoft-hosted agent, your job is to run container on that agent.

ability to run community images(docker hub) or your own private containers(Store in Azure container registry).

Callouts

  1. we will be running a script of "Hello World" inside of our Ubuntu 16.04 container hosted on the Microsoft-hosted image of Ubuntu 1804.
  2. Idea is that everything happens(downloading/building) inside of the container rather than the host machine(VM)
Non-orchestration configuration(manual)

What: manually run docker container without using an orchestration engine like Kubernetes

Orchestration configuration(AKS)

Summary
  1. Know basic process for Microsoft/self-hosted containerized agents
  2. Microsoft hosted YAML schema: declare host in container image
  3. self-hosted agent process: Create docker file and registration/authentication script | start/deploy an image with DevOps organization variables

Summary

Lab: Use deployment groups in Azure DevOps to deploy a .net app

Objective:

Solution

Steps

  1. Create a build pipeline and build the solution // to get the artifact, ARM template and application file, DACPAC file
  2. Create release pipeline
  1. Left blade, click on release
  2. Select template window → Click on empty job
  3. Add an artifact
  4. Source type: build
  5. Enter Devops project, source
  6. Clink on stage 1 (1 job, 0 task)
  7. Unser agent job click +
  8. Search ARM template deployment
  1. Create Azure service connection
  1. Azure resource manager
  2. Service principal manual
  1. Azure resource manager connection: enter Azure service connection
  2. Enter template         
  1. Add a new task to Deploy sql database
  1. Task: azure sql database deployment
  1. Service connection
  2. Authentication type: sql server
  3. Azure sql server: database server name.database.windows.net,1433
  4. Database
  5. Login
  6. Password
  7. DACPAC file: from artifact
  1. Create release

Note: up till now, you have all your resources(VM, database, storage, network) created in the resource group and now create the deployment group to deploy application

  1. Create deployment group from azure DevOps
  1. Name: prod
  2. Use a PAT in script for auth
  3. Copy script to clipboard button
  4. In VM, PowerShell, paste the script
  5. On deployment group → target → you’ll have VM
  6. On release pipeline → edit pipeline
  7. Add a job: deployment group job
  8. Task: manage IIS website
  9. Task: deploy IIS website

Lab: Integrate GitHub with Azure DevOps pipelines

Chap - 9: Designing a package management strategy

Introduction

What is package manager/software package

What: is a software package from the perspective of the end-user and development

Discovering Package Management Tools

Development-related package managers (perspective)

Package management

How to manage packages

DevOps perspective

Packages integrated into broader applications

When we are working with package managers within a DevOps application that just

Maven, NuGet, etc, you want to start thinking about those packages of code integrated into much larger applications or bundled in-package dependencies to your code that are stored in an upstream format.

Upstream packages hosted in package hosting service

Package hosting service example

Package hosting service =  pipeline artifact single source of truth(for storing managing and providing access to artifact in packages within your organization)

  1. Azure artifact
  1. natively integrated into Azure DevOps
  1. External tools
  1. GitHub package (GitHub)
  2. Jfrog Artifactory
Summary
  1. Software packages: application deployment tool(bundled set of tools to make  deploying your application a lot easier)
  2. DevOps perspective: Upstream dependency/deployment(software packages that act as dependencies to our broader application)
  3. package hosting service: package artifact source of truth(where’s your package and artifact live)

Exploring Azure artifact

Azure artifact

What:

  1. package management hosting service built directly into Azure DevOps org
  1. Integrate files between pipeline stages using Azure artifact features
  1. Control artifact management/access with feed
  2. Support private and public registry
  1. Public registry in public DevOps project
  1. Currently supports Maven, nuGet, NPM, Python packages
Feeds

To Store, manage, group and share packages

  1. pipelines publish artifacts packages to feed in Azure artifacts
  1. share internally or publicly
  1. feeds scoped to organization or project
  1. public feed always scope to public project
  1. developers can connect to feed for upstream packages
  1. process varies by languages/tools
Developer workflow with Visual Studio

Build pipeline: publish artifact into Azure Artifact feed

Azure artifact feed: from feed, our developers are going to access and push down artifact to their own local development environment in order to work with publish upstream dependencies

Visual Studio Upstream packages: authenticate and connect to that feed via visual studio before the developer can go ahead and pull those published packages down to their own environment to go ahead and develop their broader application.

Microsoft is expect that you're familiar with the process of working with Visual Studio to authenticate with an Azure Artifact feed,

Demo: Connecting to feeds in visual studio

Authenticate and connect to NuGet feed

  1. From VS authenticate with credential provider
  1. Natively built into visual studio
  2. no need to use API keys or access tokens
  3. OAuth authentication
  1. Add packages URL to NuGet package Manager in VS
  2. Other languages/workflows may use personal access tokens(PAT)

Steps:

  1. publish demonstration code to an artifact (by running the build pipeline)
  1. create a new feed
  1. visibility: members of your org
  1. pipeline file will publish NuGet package/artifact to this feed
  2. run pipeline (pipeline file in GitHub repo)
  1. In YAML: Feed the name in our pipeline file needs to match our feed name in Azure artifact
  1. View feed connection options
Summary
  1. Azure artifact: Azure native package management
  2. feeds: package access management | connect to local development environment
  3. Visual studio feed authentication: use credential manager | other development methods use PAT

Creating a versioning Strategy for Artifact

Proper versioning strategy

why do we care about versioning strategy

  1. As the application develops multiple versions of artifact/packages will be created
  1. well developed versioning strategy = better management
  1. packages are immutable
  1. cannot be edited or changed after creation
  2. Version number permanently assigned with your package - that cannot be edit/reused
Versoning recommendations

Feed views

Demo
Summary
  1. importance of versioning strategy:  necessary for large multi-version application
  2. recommended versioning format:  semantic + quality of change. Ex: 2.1.3-release
  3. Azure artifact feed view: manage access to packages in multiple state of readiness

Summary

Chap - 10: Designing Build automation

Integrate external services with Azure pipelines

Scenarios for connecting external tools

Why do you need external tool

  1. Scan open source code/package vulnerabilities
  1. Flag for known security risk
  1. Test code coverage
  1. Is all your code being used
  1. Monitor code dependencies
  2. Integrate with other CI/CD products
  1. Jenkins
  2. CircleCI
External tool connection methods

Depend on Service/Purpose

  1. Visual marketplace
  2. Service hooks
  3. Service connector

External service authentication

  1. Personal access token
  1. Azure side authentication
  1. API token (authorization token)
  1. External service authentication
Popular code scanning service/tools

Summary
  1. Why Use external tools? - to scan code and integrate with external services
  2. External connection methods: marketplace | service hook | service connecter
  3. Authentication methods personal access token | in-app authorization
  4. Popular code scanning tools: WhiteSource Bolt | Synk | Octopus Deploy

Visual Studio Marketplace Demo

VS marketplace feature built into Azure DevOps to install and use external service

Demo

  1. add the WhiteSource Bolt extension via visual studio marketPlace
  1. browse marketplace from Azure DevOps
  2. find WhiteSource Bolt and install it
  3. select Azure org
  4. Navigate to pipeline and find the WhiteSource Bolt option
  5. register for free trial - 30 days
  6. add WhiteSource Bolt task into your YAML pipeline
  1. run extension as a task and check vulnerabilities

Exploring Testing Strategies in your build

Why test code?
  1. Good quality assurance process
  1. find bugs, fix errors, improve quality
  1. manual or automated process
  1. automatic test built into pipeline
  1. multiple testing methods
  1. test at a granular or wide scope
Testing methodologies

range in scope

Azure test plans

Summary
  1. Why test code?: Quality assurance process
  2. Testing methodologies/scope: unit | integration | functional/system | UI
  3. Azure test plans: Browser-based, manual/explanatory test management

Understanding code coverage

What is Code Coverage

How much code is used

More in-use code

How code coverage tests work

How a code coverage test is set up?

  1. test it in a local development environment, such as working within Visual Studio.
  1. The Visual Studio application itself has its own built-in code coverage tests that you can run on various different code basis.
  1. Azure pipeline job
  1. Built into pipeline task
  2. Schema varies by language/framework.

 

Code coverage frameworks

Demo
  1. Run demo pipeline configured to publish code coverage results
  2. review court coverage results
Summary
  1. what is code coverage? - measure code usage // more code in use = Les bugs
  2. code coverage frameworks: based on language/package

Summary

 

LAB: Create and Test an ASP.NET Core App in Azure Pipelines

scenario[a]

  1. you have a .net core sample app that you must push through Azure repos
  2. create a pipeline to integrate the code in Azure repos
  3. include a build and test stage in your pipeline and verify success

Lab: Use Jenkins and Azure DevOps to Deploy a Node.js App

Scenarios:

  1. you have an node JS application that you must apply to Azure web app
  2. you must use Jenkins for the integration and Azure for the deployment
  3. Create a Jenkins VM, build your pipeline, and verify app is present

Steps:[b]

  1. You need a VM which has Jenkins installed
  2. Unlock the jenkins
  3. Create a username and password
  4. In Jenkins configure build steps
  5. From Azure side
  1. Create service connection:
  1. Azure resource manager → service principal manual
  1. Create service connection
  1. Jenkins
  1. Server URL
  2. Username & password
  1. Create pipeline
  1. Add artifact: jenkins
  1. Add service connection: jenkins
  2. Jenkins job

Chap - 11: Maintaining a build strategy

Introduction

Overall tips and best practices to

Discovering pipeline health monitoring

Tools to troubleshoot pipeline issues

Scenarios for monitoring pipeline health

Pipeline issues

Pipeline reports

Solution: to use to troubleshoot pipeline issues. Which is divided into 3 sub-modules

  1. Pipeline pass rate

What: whether pipeline successfully completed or not(without any stage failure)

Detailed pass rate breakdown

  1. Test pass rate

What: detailed test report(just like pipeline but it’s a test report)

  1. Pipeline duration

what: gives detailed breakdown of the build time for each individual step or task in our pipeline

Demo
  1. View analytics in pipeline with both successful and failed runs

Steps

  1. pipelines —> select your pipeline
  2. click on analytics
  3. see all 3 options to see the summary report
Summary
  1. how do you troubleshoot pipeline problems? -  pipeline reports
  2. Pipeline reports features - pipeline pass rate | test pass rate |  pipeline duration

Improving build performance and cost efficiency

improving performance and managing the cost of your different build pipelines

Build performance and costs

Perspective: parallel agent pool increase

Perspective: longer queue time for same agents

faster builds = lower costs

Pipeline caching

Reuse outputs between jobs

Self-hosted agents

Use to reduce cost

  1. customize to hardware
  1. more power for bigger builds
  1. lower money cost
  1. self-hosted: $15/mo
  2. MS-hosted: $40/mo
  1. reuse assets between builds = shorter build times
Agent Pull consumption reports

answers/forecast how many build agents to we really needed

Summary
  1. shorter build time = lower costs
  2. Pipeline caching: share outputs between jobs
  3. self-hosted agent: custom hardware |  lower cost | reuse assets
  4. Pool consumption report: view past agent usage

Exploring build agent analysis

how to get detailed log output from our build agents in order to more properly troubleshoot successful and failed builds

Scenario: Troubleshoot Pipeline Failures

Jobs failing due to error

Watch pipeline logs

Viewing logs

Expand job summary to view logs

Downloading logs

Download logs from pipeline

Configure verbose logs

To get more detailed logs

How:

Before pipeline run, enable system diagnostics 

Purple logs are verbose logs that you won’t get with default pipeline run

Demo
Summary
  1. View pipeline logs to troubleshoot pipeline errors
  2. viewing and download logs: pipeline run information
  3. verbose logs: detailed logs for further analysis.

Summary

Chap - 12: Designing a process for standardizing builds across organization

What: modify once, update everywhere.

Implementing YAML templates

YAML template purpose

Idea: create a generic YAML template and insert into other pipeline files

Why: so you don’t have to write everything again, rather you can use the template that has common tasks that can be used in othe pipeline files

Inserting templates
  1. Create a template
  2. Insert template into other pipeline

Template location reference

Task Groups

Task group is to classic pipelines

YAML templates are to YAML pipelines in which task groups allows us to bundle and manage a set of multiple steps for a classic pipeline in a single place and then insert or import that into multiple other pipelines

Demo
  1. create a template file with build steps
  2. modify pipeline Yaml to reference template
  3. Run pipeline
Summary
  1. template purpose: reusable pipeline content
  2. inserting templates: call template reference
  3. Template location reference: same repository | separate repository

Incorporating valuable groups

Variable group purpose

Apply variable group and apply same variable groups to multiple yaml pipelines which will call upon that variable group

Pipeline variables

Creating variable groups

Pipeline variables only accessible to that pipeline

Whereas variable group are accessible in multiple pipeline. Just need to insert variable groups in the given pipelines

If you’re mixing variable group and pipeline variable, while defining pipeline variable, name and value filed is requires(whereas if you’re only using pipeline variable it takes direct name and value of the variable and don’t need to define name and value and then assign both field)

Using variable groups

Demo
  1. create a variable group
  2. modify customer website pipeline to use variable group
Summary
  1. Variable group purpose: reusable variables
  2. creating a variable group
  3. using a variable group in pipeline YAML

Summary

Chap - 13: Designing an application infrastructure management strategy

Exploring configuration management

What is configuration management

What:

Assessing Configuration Management Mechanism

4 categories

  1. Mutable infrastructure

What: what is the difference between a mutable and immutable infrastructure?

Scenario: Let's say I have a server that needs to be changed.

Mutable infrastructure: to make that change, we only need to make that change to that particular system in order to get our desired result.

Immutable infrastructure: you are not making changes to the system, you are reconfiguring the entire system every single time.

Mutable

Immutable

 in place updates

always zero configuration drift

Keep existing servers in services

easy to diagnose

easier to introduce change

Easy horizontal scaling

Quicker to manage

simple roll back into Recovery

 Callouts:

  1. Imperative and declarative code

Option 1 - Imperative(procedural):

Definition: If you are performing all these steps by yourself it's called imperative or procedural code.

Option 2 - Declarative

Definition: if you are just defining the end state of where you want to be and letting a program or an application handle all of the rest, it is called declarative code because you're simply saying, I want to be at my destination and letting the code handle the rest.

  1. Abstraction

All the additional steps in option 2 are abstracted from you

While all you have to do is enter the destination and GPS handles the rest

  1. Simplified code process

in order to determine if an application is installed, you're going to

Analogy

Think of the car analogy.

Defining the end state it was where we were supposed to be. The existing state is where we currently are. The logic to rectify is the directions. And reporting back is hopefully you get here.

Centralization

What:

Agent-based management

What: There is an agent executable that needs to be installed on a server in order for it to be properly managed.

Summary
  1. Mutability: the ability of an environment to be changed
  2. Imperative language: is coded by full logic flow
  3. Declarative language: is coded by end state
  4. Centralization is whether a primary server gives instruction and receives feedback
  5. Agent-based enforcement requires a program to be installed on enforced machines.

Introducing PowerShell Desired State Configuration (DSC)

Aspect of PowerShell DSC
  1. Mutable: You make changes on the existing systems without having to redeploy the entire infrastructure.
  2. Declarative: if you want something to happen, you state that you do want it to happen, and the code on the backend is abstracted
  3. Centralized or Decentralized: it is decentralized. However, you can make a server for it, making it centralized.
  4. Agent-based: However, for all Windows systems, it works on the Windows Management Framework.
Important consideration of PowerShell DSC
  1. CI/CD: DSC Is best used in CICD pipelines to maintain state
  2. Applications: configurations made by PowerShell DSC can be applied in Azure automation
  3. DscBaseline: covers common DSC module and creates configuration files based on a target system
Anatomy of PowerShell DSC

Summary
  1. PowerShell DSC: declarative and mutable configuration as code
  2. Contains configurations, nodes, and resources

Implementing PowerShell DSC for app infrastructure

Primary uses for PowerShell DSC

System

Application

Azure automation for enforcing configuration across your enterprise

Pipelines for CICD workflow in DevOps

Demo: Setup PowerShell DSC for DevOps pipeline
Summary
  1. automated CICD pipelines help update software faster and more reliably, ensuring all code is tested
  2. release definitions can deploy to an environment with every code check in

Summary

Lab create a CICD pipeline using PowerShell DSC

Agenda: You need to deploy a Windows server with IIS installed via CI/CD pipeline. Given the appropriate ARM templates, deploy this VM to Azure using Azure DevOps.

Chap - 14: Developing Deployment Scripts and Templates

Understanding deployment solution options

Deploying code

Deploying code to production has some process to go through

Deployment solution
  1. GitHub Actions
  2. Azure pipelines
  3. Jenkins
  4. CircleCI
  5. ARM
  6. Terraform
  7. VS App Center
  8. Others!
Aspects of a deployment

Topics for evaluating deployment solutions

Summary
  1. Aspects of deployment: configuration, data and process
  2. lots of deployment solutions: and many right answers for a deployment scenario
  3. evaluating is primary based on usage complexity and integrations.

Exploring infrastructure as code: ARM vs. Terraform

Comparison

Azure

Terraform

Azure-specific // will not be able to use in other cloud

Multi cloud provider

Latest resources // as soon as Azure update change

Slower for new resources

No state file // some tools look for existing state of infrastructure prior to make changes → ARM template is always Net-New // no state file

Relies on state file // review existing env, create state file, based on this info it will make change to the env

No clean up command

Built-in cleanup command

Code differences

Demo: ARM template in Azure pipeline

Objectives:

  1. Create pipeline
  2. Add ARM template task
  3. Install terraform
  4. Add terraform task

Callouts:

  1. Validation only: will just validate the ARM template and make sure that it works.
  2. Complete: In resource group, if there is anything that does not currently exist or is part of this template file, then it will be deleted inside of that resource group.
  3. Incremental: it will not look at the existing resources inside of the resource group, it will just add whatever is inside of the template.
Demo: deploying terraform in Azure pipeline

Callouts

  1. Init: when you start the initialization, you are initializing the working directory for the configuration files.
  1. This file going to be used throughout the validate, plan, validate and apply, and destroy phases.
  2. Asks
  1. Storage account: where you host the Terraform files
  2. Container: where you host the Terraform files
  3. Key file: is the state configuration file
  1. Once done, it's going to read the entire container of all the Terraform files I have inside of it, and when I do something like plan, and validate and apply, it's going to look at all of the Terraform files that I have inside of that container and plan and validate those.
  1. Plan: review the changes and identify what's going to be changed inside of the infrastructure, based off from the previous state configuration file or none, if there's none currently available.
  2. Validate and apply: validate the files and apply them towards the infrastructure actually making changes.
Summary
  1. Comparison: Azure specific versus universal cloud provider
  2. Code formats:  terraform = .tf | ARM template = .json
  3. working together: terraform can deploy arm templates.

Exploring infrastructure as code: PowerShell vs. CLI

Code differences

Comparison highlights

Powershell

CLI

Both are very similar

For example, you can build Azure CLI with other programming languages like Python

Go with what you’re familiar with

Demo: Deploying with both PowerShell and CLI

Objectives: deploying with both power shell and CLI

Summary
  1. Comparison: very similar in both usage on deployment
  2. PowerShell: has several ways to reuse existing scripts.

Linting ARM Templates

What is linting

What: it’s a code analyzer that looks for error and problems in your code.

Once its found errors, it's your duty to remove error

Demo

Objectives: Validate ARM template Code

Steps:

Summary
  1. Linting: is the process of checking static code for errors, usually by a tool
  2. common checks include: programmatic and stylistic errors, although some tool can be used for more

Deploying a Database

What is DACPAC?

Data-tire application package: 

Demo

Objectives: Deploy a database in a DevOps pipeline

  1. create a DevOps pipeline
  1. Job: SQL server database deploy(using DACPAC & SQL script)
  2. Deploy SQL using
  1. Sql Dacpac = select this
  2. Sql query file
  3. Inline Sql
  1. DACPAC file: supply file from your database server
  1. Go to your database
  2. Right click → tasks
  1. Export data tire application // will give bacpac (backup file)
  2. Extract data tire application // will give dacpac
  1. Specify SQL using
  1. Server
  2. Connection string
  3. Publish profile
  1. Server name
  2. Database name
  3. Authentication methods
  1. add a step to deploy SQL

 

Summary
  1. SQL DACPAC: a package containing SQL server objects(instance objects, tables and view).

Understanding SQL Data Movement

What is BACPAC?

What:

Demo

objectives: deploy a database in a devops pipeline

  1. edit a devops pipeline
  1. Job → task: Azure SQL database deployment
  2. Deploy type: SQL dacpac file
  3. Action
  1. Publish: incrementally update the database schema to match the schema of DACPAC file. If files not exist on server then it will create the database file; otherwise exiting database gets updated  
  2. Extract:  create the DACPAC file// contains schema info
  3. Export: create the BACPAC file // contains the data and database schema
  4. Import: import the schema from BACPAC file
  5. Script: is whatever T-SQL statement script you need
  6. Drift Report: create an XML report of the changes that have been made since it was last registered
  7. Deploy Report: create an XML report of the changes that would be made by publishing

  1. add a step to deploy SQL
  2. additional SQL flow actions: extract, publish, export, import, deployReport, driftReport, script
Summary
  1. SQL BACPAC: A package containing SQL Server schema and data
  2. SqlPackage.exe: allows data flow by special actions
  3. BACPAC Commands: Export, import
  4. DACPAC commands: extract, publish

Introduction to Visual Studio App Center

What is App Center

What: App Center allows you to deploy your application to multiple destinations

Demo

Objectives:  Integrate App Center with DevOps pipelines

  1. Create a pipeline
  2. Add an App Center step
  1. Task:
  1. Add App Center test
  2. Add App Center distribute
Summary
  1. App Center: mobile development lifecycle solution
  2. Supports: iOS, android, Windows and Mac OS app
  3. Integrates with Azure DevOps pipeline

Exploring CDN and IOT deployments

Azure CDN deployment with DevOps pipeline

Flow is same as aws = S3 bucket + CloudFront

Azure IOT Edge deployment with DevOps pipeline

Demo

objectives: deployed to an IOT device with DevOps pipelines

  1. create a new IoT edge pipeline
  2. add an IoT deployment step
  3. review process
Summary
  1. CDN: deployments have steps for compression and caching before publishing
  2. IoT edge pipelines can be integrated with the IOT hub
  3. DevOps starter can be used to quickly set up some simple projects

Understanding Azure Stack and sovereign cloud deployment

Exploring environments

Demo

Objectives:  explore environments

  1. review the environment options in service connections
Summary
  1. environments can be changed in Azure pipelines by defining service connections
  2. security and compliance assessments: can be done on pipeline to ensure security because Azure DevOps does not run on Azure Government or Azure China

Summary

Lab: Build and Distribute an app in App center

What: Visual Studio App Center applications and distribution groups. In this scenario, we will create an application in App Center and then create a distribution group with an external user to be notified when there is a new build, which will help with collaboration across the development lifecycle.

LEARNING OBJECTIVES

Scenario

  1. your team wants to increase collaboration with external users across the development cycle
  2. create an application in visual studio app centre
  3. create a distribution group to notify external users of new builds via email

Steps

  1. Create Azure DevOps project
  1. From project setting: policy → run on third-party application access via OAuth
  1. Import repo from GitHub
  1. Sign in to appcenter.ms
  1. Personal company or school
  1. Add new app
  1. Select name, OS(windows), platform(UWP)
  1. Under settings → people → add invite email
  2. Under distribute → group → add group
  1. Give name
  2. On - allow public access
  3. Invit email
  1. Under build → Azure DevOps
  2. Select your project
  3. Select your branch
  4. Build → App Center → configure build
  1. On: distribute build
  2. Enter the group name
  1. Save

Lab: Linting your ARM templates with Azure pipelines

Scenario:

  1. In order to ensure there are no errors in your deployment so you need to lint the code
  2. take the provided ARM templates and ensure there are no JSON errors
  3. do all of this only using Azure pipelines

Steps

  1. Create a new Azure org
  2. Push the ARM template into Azure repo
  3. Create a pipeline with limiting
  1. Task: npm
  1. Command: custom
  2. Command and argument: install jsonlint -g
  1. Task: cmd
  1. Script: jsonlint template.json

Lab: Building infrastructure with Azure pipeline

Scenario: You have been given an ARM template for a Linux VM to deploy to Azure. Using Azure DevOps, you must check the ARM template for errors (linting), and deploy the VM to the provided Azure environment.

Steps:

Create an Azure DevOps Organization

Push Code to Azure Repos

Create the Build Pipeline

Create the Release Pipeline

Lab: Deploy a python app to an AKS cluster using Azure pipeline

Objectives: You are responsible for deploying a Python app to AKS. You have the code and a pipeline template, and you must create a CI/CD pipeline in Azure DevOps.

Steps:

  1. Create an Azure DevOps Organization
  2. Import Code and Setup Environment
  1. Pipeline → environment → create a new environment
  1. Name: dev
  2. Resource: kubernetes
  1. Provider
  2. Azure subscription
  3. Cluster
  4. Namespace
  1. Service connection: docker registry
  1. Create Azure container registry via Azure CLI
  1. It has access keys, input this detail into service connection configuration
  1. Enter docker registry
  2. Docker ID
  3. Password
  4. Name
  5. Grant access to all pipeline  
  1. Create the CI/CD Pipeline
  2. Access the AKS Cluster

Chap - 15: Implementing an Orchestration Automation Solution

Exploring release strategy

Canary deployment

What: 

Rolling deployment

What 

Blue/Green deployment

What 

Rolling

Canary

Blue-green

Use-case

benefits applications that experience incremental changes on a recurring basis, small changes

can work well for fast-evolving applications and fits situations where rolling deployment is not an option due to infrastructure limitations.  

                                                                                                                                                                                             

doesn't require any spare hosting infrastructure

requires a large infrastructure budget, best suits applications that receive major updates with each new release

How

Updates few existing server with the new version of the code.

Old and new applications runs parallelly.

If no bug found(on updated server) then all the remaining old coded server gets un update with the new code. // no new servers  

Same as rolling where the new release available to some users before others. However, the canary technique targets certain users to receive access to the new application version, rather than certain servers.                                                                                                                                                                                                  

A common strategy is to deploy the new release internally -- to employees -- for user acceptance testing before it goes public.

maintain two distinct application hosting infrastructures. At any given moment, one of these infrastructure configurations hosts the production version of the application, while the other is held in reserve // swap                                                                                  

deploy a new app version to reserved infrastructure(staging env) —> test staging deployment —> swap traffic from one infrastructure to the other // staging becomes production and former production goes offline

Not suitable

Applications that get major update // because user gets the old version of the features which defeats the purpose

Analogy

offers a key advantage over blue/green switchovers: access to early feedback and bug identification —> canaries, find weaknesses and improve the update before the IT team rolls it out to all users.

Summary
  1. Canary deployment: deploy in a small part of the production infrastructure only a few users are routed to it until sign off
  2. Rolling deployment: YouVersion gradually replaces the old one coexisting
  3. Blue/Green deployment: two identical hardware environments, one active one idle

Exploring stages, dependencies and conditions

Release pipeline stage anatomy
Stages

Pipeline flow:

 

Stages: stages are logical boundaries in your pipelines where you can pause the pipeline and perform various checks.

Dependencies

Properties 

  1. dependsOn A #This stage runs after stage A
  2. dependsOn: [] # this stage runs in parallel to stage A
Conditions

Properties

  1. condition: succeeded(‘A’)
  2. condition: failed(‘A’)
Full stage syntax

Summary
  1. stages organized pipeline jobs into major divisions
  2. dependencies are used to run stages, subsequently, in the order you specify
  3. conditions customize behaviors and reactions to other stages

Discovering Azure app configuration

The INI File

How can you deploy app configurations?

Idea:

What is Azure app configuration

What

Azure app configuration benefits
  1. fully managed service
  2. point in time replay of settings
  3. flexible key representations and mappings
  4. dedicated UI for feature flag management
  5. tagging with labels
  6. comparison of 2 sets of configurations
  7. enhanced security through Azure manage identities encryption of sensitive information
  8. native integration with popular framework
  9. works with Azure keyvault
Demo

objectives: create an Azure app configuration store:

Steps:

  1. create an app configuration store
  1. in Azure portal: create a resource - App Configuration
  2. configure settings
  3. access keys: use it in your code to connect to Azure app configurations
  4. configuration explorer
  1. key value: configure this
  2. key reference
  1. walk through the Key Vault options
Summary
  1. Application configuration settings: should be kept external to their executable and read in from their runtime environment or an external source
  2. Azure app configuration centrally manages application settings and feature flags
  3. Azure key vault: can be used in conjunction with Azure app configuration

Implementing release gates

What are gates

Gate sits between code and deployment

Gate has some sort of criteria making sure that the code is properly prepared and series of checks and balances

Scenarios for gates
  1. incident and issues management
  2. seek approval outside Azure pipelines
  3. Quality validation
  4. security scan on artifacts
  5. user experience relative to baseline
  6. change management
  7. infrastructure health

Manual intervention and validations

two places where you can put gates

  1. pre-deployment conditions between code and deployment
  2. post-deployment conditions after the code deployment

manual interventions task pause the pipeline ensuring that somebody can get some type of work accomplished before the end of the gate

manual validation is an approval for the same thing, it will pause the pipeline until it gets a form of approval before moving on

Demo

Objective set up gates on a release pipeline

  1. set up gates
  1. on pipeline enable gates
  1. set up manual intervention // write instruction, notify user, reject/resume based on time
  1. on job, add a task: manual intervention
  1. set up manual validation // write instruction, notify user
  1. on job, add a task: manual validation
Summary
  1. Gates ensure the release pipeline made specific criteria before deployment
  2. manual intervention is a task step
  3. manual validation is an approval step

Summary

Lab: Creating a multi-stage build in Azure pipeline to deploy a .NET app

Scenario

  1. A.net core app needs to be deployed to Azure
  2. create a multistage YAML pipeline using YAML
  3. After the building deploy stages are complete verify you can access the application

trigger:
- stage

variables:
 buildConfiguration:
'Release'

stages:

- stage: Build
 
jobs:
 - job: Build
   pool:
     vmImage:
'ubuntu-latest'
   steps:
   - task: DotNetCoreCLI@2
     inputs:
       
command: 'restore'
       projects:
'**/*.csproj'
       feedsToUse:
'select'

   - task: DotNetCoreCLI@2
     inputs:
       
command: 'build'
       projects:
'**/*.csproj'

   - task: DotNetCoreCLI@2
     inputs:
       
command: 'publish'
       publishWebProjects:
true
       arguments:
'--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'

   - task: PublishBuildArtifacts@1
     inputs:
       PathtoPublish:
'$(Build.ArtifactStagingDirectory)'
       ArtifactName:
'drop'
       publishLocation:
'Container'

- stage: Deploy
 
jobs:
 - job: Deploy
   pool:
     vmImage:
'ubuntu-latest'
   steps:
   - checkout: none

   - download: current
     artifact: drop

Chap - 16: Planning the development environment strategy

Exploring release strategies

Deployment strategies and steps

Steps regardless what strategy you use

  1. enable initialization
  2. deploy the update
  3. route traffic to the updated version
  4. test the updated version
  5. in case of failure run steps to restore the last known good version
Deployment representations

you have 2 server (active/live + inactive/standby)

Deployment releases using virtual machines

Blue - Green

Canary 

Rolling set

Deployment jobs

Summary
  1. Deployment groups are used on virtual machines with build/release agents, separated by tags
  2. Deployment strategies: all techniques enable initialization, deploy the update, route traffic, and test
  3. Deployment jobs: YAML is a very quick way to view all lifecycle hooks

Implementing deployment slot releases

What are deployment slots

Virtual machine has deployment groups = Azure webapps has deployment slots

Demo

objectives:  Review deploy slots on an app service

  1. Open a Web app
  1. Under function app
  2. Add a slot
  1. Staging // will create another live app with its own hostname
  1. When you ready swap to staging
  1. Review deployment slot options
Summary
  1. Deployment slots: live app services with their own Hostnames
  2. Alternative to deployment groups: content and configuration elements can be swapped between two deployment slots
  3. Rolling and cannery strategies: are handled by specifying traffic % between the slots

Implementing load balancer and traffic manager releases

Load balancer and traffic manager

Load balancer: routs traffic inside a region

Traffic manager: routes traffic globally  

Idea is global traffic management combined with local failover

Demo

Objectives: Azure traffic management in DevOps pipeline deployment release

  1. create a deployment release
  2. add a load balancing step
  1. from pipeline, add deployment group
  2. Job:
  1. add deployment group
  2. Restart load balancer
  3. Start load balancer
  1. Add Azure traffic manager steps
  1. Create a resource → traffic manager profile
  2. Routing method: performance
  3. Pipeline job/task → Azure traffic manager

what: route traffic between multiple servers

Summary
  1. Azure Traffic manager: global policy based routing
  2. Load balancer: inter-regional routing

Feature toggles

Feature flag branching

Demo

Integrate feature flags in pipeline deployment release

  1. integrate an app with feature flags into Azure DevOps
  1. Feature flag via app called launch darkly
  2. Add a task: launch darkly
  1. Set flag state: On
  1. Roll out feature flags in release pipeline

Summary

Lab: Deploy a node JS app to a deployment slot in Azure DevOps

Chap - 17: Designing an Authentication and Authorization Strategy

Azure AD Privileged Identity Management(PIM)

Why use Privileged Identity Management?

Idea

What is PIM?
What does it do?
  1. Just in time: enables just-in-time privileged access to Azure Active Directory and Azure resources
  2. Time bound: can assign time-bound access to resources using start and end dates
  3. Approval: can require approval to activate privileged roles
  4. Multi-factor: enforce multi-factor authentication to activate any role
  5. Justification: can provide justification and enforce justification to understand why users activate.
  6. Notification: notifications for when privileged roles are activated
  7. Access review: can conduct access reviews in order to ensure users still need the roles that have been assigned to them
  8. Audit history: can have audit history where you can download for internal or external audits

How does it work?

Summary
  1. Privileged identity management: enables management, control and monitoring of resource access
  2. Azure AD integrated: this service is part of Azure AD
  3. Activation you can require MFA, approval and justifications

Azure AD conditional access

Why use conditional access

Signals: In order for a person to access resources, it can send out a signal.

Example

Idea

What is Azure AD conditional access
What does it do

For common signals we have

For Common decisions are to

How it works

Summary
  1. what it is: a set of if-then statement policies that enforce actions
  2. anatomy: signals, decisions,and enforcement
  3. common signals: membership, location, device, or application, and real-time risk analysis

Implementing multi factor authentication(MFA)

What is MFA
How it works & Available verification methods
Enabling multifactor authentication

Signal → decision → enforcement

Demo

Objective: Enable MFA for Azure DevOps

  1. create a conditional access policy
  1. in Portal → Azure AD → security → conditional access
  2. Create a new policy
  3. Configuration
  1. User and groups
  2. Cloud apps: office 365
  3. Condition: device platform - IOS
  4. Grant access: require MFA
  5. Session: don’t need
  1. require MFA for web access
Summary
  1. enabling MFA: create a conditional access policy with grant conditions

Working with service principals

Using service accounts in code

What:

What are Azure service principles

How to access resources with service principals

Summary
  1. Service principal: a proxy account or identity for an app or service
  2. Requirements: directory (tenant) ID, application (client) ID, and credentials

Working with managed identities

What is managed service identity (MSI)

Source and Consumer model:

2 types of MSI

  1. System managed identity
  1. it's tied to your application resource, and is deleted if your app is deleted.
  2. each app can only have one system-assigned identity
  1. User assigned identity
  1. Standalone - can be assigned to your application resource.
  2. The app can have multiple user-assigned identities

Demo

Objectives: Create a system and user managed identity in Azure

  1. assign a system managed identity to an Azure VM
  2. add role assignments
  3. add a user managed identity
Summary
  1. Managed identity: in Azure resource identity that allows access privileges to other Azure resources
  2. System managed identity: tied to your resource or app and is deleted if the resource is deleted

Using service connections

What is it

When you want to access other/remote services you need service connection to be able to access that remote service

Demo

Objectives: manage service connection in Azure DevOps

  1. create, manage, secure and use service connection
Summary
  1. Service connection: enables a connection to an external or remote service do execute tasks in the job

Incorporating vaults

What are key vaults

Key Vaults To

Azure key vaults

stores secrets and make them available to consumer like a Azure DevOps pipeline

Azure key vault using a DevOps pipeline

to connect Azure DevOps to Key vault we need service principal

Azure DevOps Phil connect to service principal, obtain the secret, and use it to deploy targets

Using HashiCorp Vault with Azure Key vault

Hashi Corp. vault can automatically generate service principles and use for Azure DevOps

you can’t use Hashi carpool vault and Azure Key Vault together

Demo

Objectives: use Azure Key Vault in a pipeline

  1. create a key vault
  2. configure service principal
  3. retrieve secret in a Azure pipeline
Summary

Lab: Read a secret from an Azure key vault in Azure pipelines

Summary

Chap - 18: Developing Security and Compliance

Understanding dependency scanning

Dependencies

Direct dependencies: When you build code, there are packages and libraries that you use as part of your code. These are known as direct dependencies.

Transitive or Nested dependencies: There's also a chance that some of your packages and libraries or dependencies that you use also have additional packages or libraries

Type of dependency scanning
Security dependency scanning

Security dependency scanning means

Compliance dependency scanning

What:

Main compliance 

  1. General Public License (or GPL)
  2. MIT license.

Aspects of dependency scanning

Summary
  1. Dependencies: packages and libraries that your code uses
  2. Security dependency: scanning access dependencies against non-vulnerabilities
  3. Compliance dependency scanning: access dependencies against licensing requirements

Exploring container dependency scanning

Aspects of container scanning
  1. Scanning: base image files for audits
  2. Updates: recommended container image versions and distributions
  3. Vulnerabilities: match found vulnerabilities between the source and target branches

There is a different type of containers scanning depending on what containers you use

  1. Docker enterprise: scanning in docker trusted registry
  2. Docker hub: uses Snyk and repo scanning
  3. Azure Container Registry: Qualys scanning Azure security center
Demo

Objective: scan a container for dependencies

  1. Navigate inventory in security center
  2. review Kubernetes recommendations
  3. review Azure container registry image recommendations
Summary

Incorporating security into your pipelines

Securing applications
Continuous security validation process

Secure application pipelines

Summary
  1. Securing applications: secure infrastructure, designing apps, architecture with layered security, continuous security validation, and monitoring for attacks
  2. Continuous security validation: should be added at each step from development to production
  3. passive/active tests: passive run fast, active runs nightly

Scanning with compliance with WhiteSource Bolt, SonarQube, Dependabot

  1. WhiteSource Bolt

Objectives: scan for dependency compliance using WhiteSource Bolt

Steps:

  1. SonarQube

Objectives: skin for dependency compliance using sonarQube

Steps

  1. Dependabot

Objectives: scan for dependency compliance using Dependabot

Steps:

  1. in GitHub, go to setting, security and analysis
  2. enable: dependabot alerts
  3. go to security, dependabot alerts // to see the alerts

Summary

Chap - 19: Designing Governance Enforcement Mechanisms

Discovering Azure policy

Scenario
  1. Security team is struggling because dev and test environments are not matching up with production In terms of their configuration
  2. They have introduced a security policy but resources are not being deployed with proper security settings such as encryption
  3. Want to report an enforce standard across the organization
Azure policy

IMP: Azure policy can also be integrated into Azure DevOps pipelines by adding a gate as a pre-or post-deployment action When you configure security and compliance assessment

Azure policy Access

Demo
  1. Explore Azure policy
  1. In Azure pipeline → Azure policy → definitions
  2. From drop-down definition type → policy
  3. Search encryption:  all disks on VM should be encrypted
  4. Select assign
  1. Select scope: RG
  1.  Azure policy → definitions → initiative definitions
  1. Explore Azure policy integration with Azure DevOps

Summary
  1. Policy definition describes what to look at and what action to take
  2. An assignment is a policy definition with a scope
  3. An initiative is a group of related policy definitions
  4. A policy can prevent results from being built or edited
  5. A policy can just audit the event and report it
  6. A policy can change the resource so that it meets the policy definition

Understanding container security

Azure defender for container registry

Why do you need it: most vulnerabilities come from the base images for the container

What it does: it will scan the actual container registry and scan for vulnerabilities in the container images so that you can review the findings

How: it uses Qualys scanner to do the scanning // Industry leader in vulnerability scanning

Images can be scanned in 3 types

  1. image pushed
  2. recent image pulled
  3. imported images
AKS protection

when it comes to AKS, there are 2 levels of protection that are provided in Azure Defender

AKS flow: when it comes to AKS containers, there are one or more AKS containers running in a pod → Which are hosted on a Node Otherwise known as a virtual machine or server

Cluster:  Consist of multiple Nodes(VMs), pods(running containers)

Nodes: VM or physical server running in your data centers or could be a VM in the cloud.

Pods: scheduling unit in Kubernetes(Each pod consists of one or more containers) 

Summary
  1. Azure defender: for container registry pulls images into a sandbox container to scan for one vulnerabilities
  2. The container that I scanned can be images that were pushed, recently pulled, or imported
  3. When it comes to AKS, there are two levels of protection from the host and cluster level
  4. The host level protection: will use Azure defenders for servers to analyze security and determine if there are any attacks like crypto mining or malware
  5. Azure Diffenderfer for kubernetes: provides cluster level runtime protection by analyzing the audit logs from the control plane

Implementing container registry tasks

Azure container registry

What

Tasks (Quick, Automatic, Multi-step)
  1. Quick Tasks

  1. Automatic tasks

  1. Multi-step task

Summary
  1. Quick tasks: allows you to build container images on demand without local docker tools, you need Azure specific command to build and push your images into Azure
  2. tasks can be automatically trigger based on source code changes in base image or on the schedule
  3. for more complex scenario you can configure a YAML  file to orchestrate a multi-step task with action such as build, push and CMD

Responding to security incidents

Emergency access accounts

When it comes to protecting information, one of the first steps is to

Configure emergency access accounts/break glass accounts

What: these are special accounts with high privileges that are not assigned to any specific person; rather, they're securely saved and only used in emergency situations.

Why do you need emergency access accounts

  1. administrators locked their account, or an administrator is on vacation or left the company,
  2. or possibly the federated identity provider is having an outage.
  1. And this would be a situation where the users sign into an active directory, and then the active directory checks in with a federated system that it trusts to verify the account.
  1. No access to MFA device or MFA service is down
Best practices
  1. Multiple accounts: in case there is an issue with one
  2. Cloud-only accounts: use an *.onmicrosoft account  
  3. Single location: account should not be synced with other environments.
  4. Neutral: there should not be any information tied to a specific person
  5. Alternative: authentication the account should use a different authentication method than regular accounts
  6. No expiration: password should not expire
  7. no automated cleanup: it should not be automatically removed if there is a lack of activity
  8. Full permissions it should not be hindered by confidential access policies
What to do after the accounts are configured
  1. Monitoring: configured Azure active directories alerts to make sure that the accounts are not being used inappropriately
  2. Regular checks: make sure the accounts are still active and working
  3. Training: make sure all relative parties are informed about account policies and procedures
  4. Rotating a password: on a regular basis
Demo emergency access account monitoring

Set up log based alerts against the account in Azure AF

Summary
  1. emergency access accounts are also called break glass accounts
  2. emergency access accounts should be shared accounts with the credentials saved in a secure location
  3. preparation for account outages should be considered by having multiple cloud only accounts that use a separate authentication method
  4. policies should be reviewed to make sure the account don’t expire or get deleted
  5. ongoing monitoring on the account activity is recommended
  6. The account password should be rotated every 90 days, after an incident, or after a staffing change.

Summary

lAB: Build and Run a Container Using Azure ACR Tasks

Objectives: Your manager asks you to run a container, but you don't have Docker installed on your desktop. You've recently learned about Azure ACR Tasks built into Cloud Shell and decided to give it a try. Your goal is to create a new container registry and use ACR Tasks to build, push and run the container in Azure.

Steps

  1. create a new container registry
  2. create a docker file: to provide build instructions
  3. build and run the container: all within the cloud shell

Chap - 20: Designing and Implementing Logging

Why Logging

Discovering logs in Azure

What are logs

Pieces of information that are organized into records and contain certain attributes and properties for each type of data

Ex: Server event logs which will give you properties like log name, source, ID, level, user, timestamp, category, details

Sources of logs in Azure
  1. Application
  2. VMs and Container
  3. Azure resources
  4. Azure subscription
  5. Azure tenants
  6. Custom sources
Log categories

Diagnostic log storage locations

Diagnostic logs: there are certain Azure Resource logs that are not turned on by default but give you extra information. And these are called diagnostic logs. And these need to be configured to be sent to a certain target such as Azure Storage, Log Analytics workspace, Event Hub

 

Demo exploring logs and configuring diagnostics
Summary
  1. Application in container logs provides information on deli Metairie and events on both an application and infrastructure level
  2. each Azure resource has its own unique set of logs
  3. logs are available for subscription and tenant level events such as activity logs and Azure activity directory logs
  4. diagnostics can be configured to send specified as a resource lock to Azure storage, Log analytics or and event hub
  5. diagnostic logs include retention settings
  6. with Azure storage you can configure items with hot, cool, archive storage tires

Introducing Azure monitor logs

Azure monitor logs

What 

Log analytics agent

How

Demo:
  1. Build and log analytics workspace
  1. Create a resource: log analytics
  2. Configure it
  1. Configure storage retention

Price 

  1. Daily Cap: how much data we want to be interesting per day and once you hit that amount of data then it will cap it off(you can select when)
  2. Data retention: how long you want your logs to be saved in log analytics workspace
  1. Assemble log analytics queries
  1. Go to Azure monitor → logs
  2. Use kusto query to get the result you want
  3. Example: search VM named XYZ, search top 5 VM named XYZ

Example

Meaning

Search in TABLE “Value”

Search something in the table

Where VM = “XYZ”

Search VM named XYZ

Where VM = “XYZ” | take 5

Output 5 VM

Where VM = “XYZ” | top 5 by TimeGenerated

Output most recent

Where VM = “XYZ” | sort by TimeGenerated asc

Output oldest result by sorting

Where VM = “XYZ” | top 5 by TimeGenerated | Project TimeGenerated, computer, name, val

Output specific column

Where VM = “XYZ” | summarize count () by Computer

Group records together to a specific aggregation

Log analytics agent

Summary
  1. Azure monitor log analytics were previously called operation management suite
  2. A log analytics workspace stores data from Azure resources so that they can be analyzed using the Kusto query language
  3. For Azure virtual machines, Microsoft recommends using the Azure log analytics VM extension
  4. when installing manually you will need the workspace ID and the primary key
  5. Data retention and a daily Cap can be configured in the usage an estimated costs tab
  6. KQL operators: search, where, take, top, sort, project, summarize, count
  7. KQL scalar functions: bin and ago

Controlling who has access to your logs

Scenario
How many workspaces to deploy

One Vs. Many

Access Modes

Access control modes

Built-In roles

Custom roles table access

Demo: configuring access control
Summary
  1. centralized workspaces are easier to search but harder to manage access
  2. decentralized workspaces are harder to search but easier to manage access(individual workspaces for each group that needs access to that specific data)
  3. The workspace context from Azure monitor logs has access to the whole workspace
  4. The resource context has access only to the specific resource logs
  5. log analytics reader(no manipulation) and log analytics contributor are the built-in roles for log analytics workspace access
  6. access can be granted to specific tables in the “action” section of the custom role
  7. access can be denied to a specific table in the “notActions” section of the custom roles

Crash analytics

Crash analytics

What:

Why do we need it:

How can we do this?

Visual studio App center diagnostics

What:

How:

  1. SDK: This is used to gather diagnostic information that will be used to determine what the issue is.
  2. Diagnostics:  Device information, application information, running threads, installation/user ID
What happens when a crash occurs?

Google firebase crashlytics

crash reporting tool that:

  1. uses the firebase Crashlytics SDK
  2. automatically groups crashes together
  3. suggests possible causes and troubleshooting steps
  4. diagnosis issue severity
  5. presents user information
  6. provide alerting capabilities
Demo
  1. explore visual studio App Center crashes
  1. Open App Center page
  2. Add SDK to your app
  1. explore Google firebase crashlytics

Summary

  1. Visual Studio App Center SDK is needed to gather the information used for diagnostics
  2. App center diagnostics: information can be viewed in the crashes tab
  3. diagnostic information: includes device and application information, running threads, and IDs
  4. Google firebase Crashlytics provide similar crash analytics capabilities
  5. crash information can be found under the stability section in the crashlytics tab

Summary

Chap - 21: Designing and Implementing Telemetry

Introducing distributed tracing

Scenario
Monolithic application/NTier architecture

What:

Problem: 

  1. Building 
  1. Testing 
  1. Deployment 

So when it comes to monolithic applications,

Microservices/Service-based architecture

What:

Advantages

Disadvantages

Reduced coupling: change in one component is less likely to cause an issue with another component

Complexity harder to keep track of where everything is running from

Agility: easier to build test and deploy because you can focus on each component individually

Latency: all communication between components is through network calls

Scalability: can scale components separately scalability can scale components separately

What do we monitor
  1. Throughput: how much work the application performed in a certain amount of time
  1. for example, if you have a web application, you can measure a throughput by how many completed requests per second there are.
  1. Response times: how long it takes for a call to travel from one component to the other.
  2. error rates: how many errors are we getting, or what percentage of the time are we getting errors?
  1. 400 or 500 errors
  1. Traces: is to follow an application's flow and data progression. So if there is an error, a trace can allow you to see where and why it happened.
Distributed Tracing

Why do we need it?: to address the challenges of cloud native and microservice architecture where it is hard to Keep track of what happened, where, and how are each of the separate components performing

How does it work?: tracks the events by using a unique ID across all the services on all the resources in the call stack

How do we implement it? Application Insight SDK provides this functionality by default

Demo: Application Insights tracing
Summary
  1. Monolithic architecture have all the components of an application in one artifact
  2. Microservice architecture distributes the components on individual resources
  3. Distributed tracing uses a unique ID to produce a detailed log of all the steps in the call stack
  4. Distributed tracing capabilities are provided by default using the Application Insight SDK.
  5. The application map provides a visual of all the dependencies and their corresponding connection and trace information
  6. Traces can be found in the failures blade of Application Insights

Understanding User Analytics with Application Insight and App Center

User analytics

What:

Why:

Callouts

Application Insights user analytics

View user analytics via Application Insights.

This provides

  1. Statistics on Number of users
  2. Sessions, Events, Browser, OS Information
  3. Location information - all comes from client-side JavaScript Instrumentation

Usage

usage blade in App Insight there are various sections

  1. Users:
  1. how many users visited the application.
  2. How: this number is counted by anonymous IDs that are stored in the browser.
  3. And this means that if a user changes their browser, or clears their cookies, or changes the devices that they're accessing the application from, this will look like an additional user from Application Insights perspective.
  1. Sessions:  
  1. is a certain amount of time that a user spends on your application.
  2. And that session is over when either there's no activity from the user for more than 30 minutes or after 24 hours of use with continuous activity.
  3. And this section counts how many sessions the application has had.
  1. Events: 
  1. counts how many times, pages and features have been used
  1. Funnels:
  1. to see if customers are following the path that you intended for them on the website, or if the users are leaving the site at unexpected points.
  1. User flows
  1. shows the overall general path that the users are taking on your website.
  2. It shows what parts of the page does the user click on the most and are there any repetitive actions?
Visual studio App Center analytics
  1. Active users: How many users are currently using the application
  2. Sessions: how many sessions the application had
  3. Geographic data: Where are the users accessing the application
  4. Devices: What devices are being used to access the application
  5. OS: What OS are they using on their devices
  6. Languages: what languages are used by the users
  7. Release: what version of the application is used
  8. Events: what actions the user performed on the application such as the beaches that they visit(custom events as well)
Export App Center data to Azure
Demo
  1. Explore App Center analytics
  1. In App Center → Analytics
  2. See active users, session, device info, OS, Country and languages
  1. Export data to Azure
  1. From settings → export → new export
  1. Blob: configuration is straight forward  
  2. App insight(requires instrumentation key)
  1.  Go to your Azure AppInsight instance
  2. On the essential page: get the instrumentation key
  1. Explore Application Insights User Analytics
  1. From Azure App Insight Instance → Usage // find user information
Summary
  1. A session is a period of consistent activity from a user
  2. A funnel determines if the users are following the intended path
  3. A user flow shows the general course that the user takes on the application
  4. Data can be exported from App Center by navigating to settings and then export
  5. Data can be sent to Azure blob storage or Application Insights

Understanding User Analytics with TestFlight in Google Analytics.

Google Analytics

Web analytics tool that

How to start collecting Analytics

How Google configured data

  1. Analytics account
  1. initial account can be created by logging into Google Analytics with Google account
  2. Additional accounts can be configured in the admin section
  1. Analytics property
  1. A property groups the traffic data together for a specific application
  1. Configure Stream
  1. Manually add provided site tag to the head section of application pages
  2. automatically configures stream by adding the measurement ID to Google tag manager
Demo: Explore Google Analytics

Steps:

  1. Sign into https://analytics.withgoogle.com 
  2. On the left blade, click on the Admin section - gear symbol
  3. Create account
  1. Account name
  2. Property name
  1. Create property (configure data stream)
  1. Click on Data Stream
  2. Choose a platform: Web
  3. Enter website URL
  4. Enter stream name
  1. From Tagging Instruction
  1. Global site tag (manual): if you select this then you have to embed the code  snippet provided in this page to the head section of your HTML page
  2. Google tag manager(automatic): from the page grab the Measurement ID and add it to your Google tag manager and set it to trigger on all the relevant pages
  1. On the left blade, see the user data

        

Summary
  1. An analytics property groups application traffic together so only relevant data is sent
  2. A property is created in the admin section
  3. you can manually add the site tag provided in the property to the head section of your application pages(HTML Page) to configure a stream// once it’s configured it will start sending data to your Google analytics workspace
  4. you can use the measurement ID to automatically configure the stream using Google tag manager

Exploring infrastructure performance indicators

Performance

What is it?

Why do we need it?

How do we measure it?

High-Level performance indicators
  1. Requests: the number of requests and how long it takes to process them
  2. Traffic: Amount of network traffic volume
  3. Transactions: The rates at which transactions are being completed successfully or unsuccessfully
  4. Latency: how much time it takes to complete the work
Example data correlations
  1. Concurrent users Vs. request latency: how long does it take to start the process request?
  2. Concurrent users Vs. response times: once the request has started, how long does it take to finish?
  3. Total requests Vs. error rates: how well is the system processing request?
Low-level performance indicators

Disk I/O: it is the speed with which the data transfer takes place between the hard disk drive and RAM

How to collect helpful data

Understandable: it should be clear what each performance metrics is and why it is captured

Frequency: Data should be collected at logical intervals

Scope: Data should be able to be grouped and categorized into larger or smaller scopes

Retention: Data should not be deleted too quickly to establish baselines and historical trends 

Summary
  1. Key performance indicators are metrics that tell us how well our system is performing
  2. request, traffic information, transaction data and latency are examples of common high-level performance indicators
  3. Performance indicators may be set on individual metrics or they may be set by correlating separate data points together
  4. memory and CPU utilization, number of threads, queue information, IO data, and network traffic are all examples of common low-level performance indicators

Integrating Slack and teams with metric alerts

scenario

Action groups

when setting up an alert you need to configure what the alert should be on, and what the alert should do once it’s triggered

What: Action group are the notification and action settings that can be saved for one or many alerts

Settings consist of 

  1. The name of the action group
  2. what type of notification will be sent
  3. what action to take when the alert is triggered.
Notification types
  1. Email Azure resource managers role: send an email to the users in a selected subscription role
  2. Email/SMS/Push/Voice: input specific user information to be sent to using the selected medium
Action types
  1. Automation runbook: receives a JSON payload to trigger a runbook
  2. Azure function: uses an HTTP trigger and point from an Azure function
  3. ITSM: Connect to supported ITSM tools(ServiceNow)
  4. Logic App: uses an HTTP trigger endpoint from a logic app
  5. Webhook: Webhooks endpoint for an Azure resource or third-party source
  6. Secure Webhook: uses Azure active directly to communicate with a webhook securely and put
Demo: trigger logic apps to send notifications to Teams and Slack

Steps:

  1. From Azure monitor → alerts
  2. Select resource - VM
  3. Add condition: Percentage CPU
  4. Actions: create action group
  5. Notification:  Email/SMS/Push/Voice
  6. Actions: logic apps
Summary
  1. An action group defines how and who to send a notification to
  2. Additionally, you can select to trigger an automation runbook, a function, connect to an ITSM, a logic app, or a webhook.

Summary

LAB: Subscribe to Azure Pipelines Notifications from Microsoft Teams

Objectives: In this lab, we will be learning about how to set alerts for activity from Azure Pipelines. In this scenario, we will be creating an Azure Pipelines build release and then configuring Microsoft Teams to receive the notifications for it, which will help with collaboration across the development lifecycle.

Callouts: you’ll get notifications in Teams every time you run pipelines  

Chap - 22: Integrating Logging and Monitoring Solutions

Monitoring containers

Azure monitor container insight

What:

Azure Kubernetes service(AKS)

One of the more common platforms that it's used for is Azure Kubernetes Service.

Why is it needed?

  1. Limited metrics:
  1. very few metrics available for the Container Service namespace in the Metrics Explorer out of the box
  2. So by enabling Azure Monitor Container Insights, many more metrics and analytics become available to us.
  1. Windows and Linux
  1. supports both Windows and Linux containers
  2. It uses a containerized version of the Log Analytics agent, so it's all running with Log Analytics behind the scenes.
  1. Log Analytics
  1. When you enable container insights with a new log analytics workspace, it will be created in a new resource group

AKS Container insight configuration options

Can be configured by

  1. Azure portal
  2. ARM Template
  3. Terraform
  4. PowerShell
  5. CLI
Prometheus

What:

How do Prometheus work

2 components

  1. Server: server uses data exported by targets to collect metrics. So it’s pulling metrics from the various targets at configurable intervals.
  2. Targets : each of these targets utilize exporters, which are agents that expose the data on an HTTP metrics endpoint

Metrics examples

  1. total http requests,
  2. memory limits
  3. memory usage
Prometheus and Azure monitor integration.

  1. No Prometheus Server

  1. How to integrate
Demo:
  1. Enable container insights using the portal
  1. azure portal →  Kubernetes cluster
  2. monitoring → insight → enable it
  3. See the different sections: cluster, report, nodes, controller, containers
  1. Explore container health metrics
Summary
  1. Azure monitor containers insights capture additional health metrics and logging
  2. Prometheus is a cross-platform open-source metric aggregations monitoring and alerting tool
  3. The main component of Prometheus is the Prometheus server which pulls metrics from the target exporters
  4. exporters are agents that expose HTTP endpoint for metric scraping
  5. integration requires enabling Azure to monitor container insights to install the containerized log analytics agent
  6. Microsoft provides a config map file that can be deployed to the environment for Azure monitor to pull Prometheus data
  7. URLs for scraping, Kubernetes service, and pod annotations can be edited in the ConfigMap file.

Integrating monitoring with Dynatrace and New Relic

Dynatrace
Dynatrace Integration

How to send data to Dynatrace

  1. Agent: agent installed on computer resources.
  2. Azure monitor integration: provides additional matrix for over 70 types of Azure resources
  3. Log forwarding: stream logs into Dynatrace logs from an Azure event hub using an Azure function
New Relic
Other third-party monitoring alternatives

Other third-party monitoring alternatives can monitor Azure resources but don’t have the built-in integration such as Nagios and Zabbix

Demo
  1. Azure integration with Dynatrace
  1. Dynatrace → settings → cloud and virtualization → Azure → connect new instance
  2. Configure it
  1. Azure integration with New Relic
Summary
  1. to integrate azure with Dynatrace, you will need to register an app in AAD, create a secret and then assign permissions to the service
  2. to integrate Azure with new relic you will need the subscription/tenant ID. you will also need to register an app in AAD, create a secret, and then assign permissions to the service.
Monitoring feedback loop
Feedback loops

What are they?  real time feedback sent to the developers from end-users and operators about the application

Why do we need them?  helps improve quality and reliability of the application by allowing the developers to quickly respond to feedback

how do we implement them? continuously monitor the application through all phases of its life cycle - not just production // Idea here is if anything needs to be fixed, you fix them before it goes to the production

Scenario
Demo: implement feedback loop using a logic app
Summary
  1. feedback loops allows developers to quickly respond to issue by getting real time feedback from end-users and operators
  2. monitoring should be included in all lifecycle phases to catch things before being deployed to production
  3. A logic app can be configured to trigger based on events grid events

Summary

[a]TODO: Add a solution

[b]TODO: Add a solution