Part 5
Azure Artifacts
Azure Artifacts is a service in Azure DevOps that allows teams to create, host, and share packages. It supports multiple package types such as NuGet, npm, Maven, Python, and Universal Packages, making it easier to manage dependencies across projects.
Key Features
- Package Management: Supports NuGet, npm, Maven, Python, and Universal Packages.
- Unified Feeds: Store different types of packages in a single feed, helping manage project dependencies.
- Versioning & Retention Policies: Automatically manage package versions and delete old packages based on retention policies.
- Upstream Sources: Connect to external sources like npmjs.org, NuGet.org, and Maven Central for public and private packages.
- Security: Integrates with Azure Active Directory (Azure AD) for role-based access control (RBAC), ensuring secure package access.
Supported Package Types
- NuGet: For .NET development.
- npm: For JavaScript and Node.js projects.
- Maven: For Java and Spring development.
- Python: Python package management.
- Universal Packages: General binary or file storage for distribution.
How to Use Azure Artifacts
1. Setting Up a Feed
- Navigate to your project in Azure DevOps.
- Select Artifacts from the left menu.
- Click on Create Feed.
- Name the feed and set its visibility to either public or private.
2. Publishing Packages
To publish a package, use the respective CLI command for your package type:
-
NuGet:
dotnet nuget push <package-name>.nupkg --source "your-feed-url" --api-key <your-api-key>
-
npm:
npm publish --registry <your-feed-url>
-
Maven:
<distributionManagement> <repository> <id>your-feed-id</id> <url>your-feed-url</url> </repository> </distributionManagement>
-
Python:
twine upload --repository-url <your-feed-url> dist/*
3. Consuming Packages
To use packages hosted on Azure Artifacts, configure your project’s package manager to point to your feed.
-
NuGet:
dotnet add package <package-name> --source "your-feed-url"
-
npm:
npm install <package-name> --registry <your-feed-url>
-
Maven:
<repositories> <repository> <id>your-feed-id</id> <url>your-feed-url</url> </repository> </repositories>
Conclusion
Azure Artifacts simplifies managing package dependencies across projects, supports multiple package types, and provides seamless integration with Azure DevOps for efficient and secure package management.
Permissions in Azure DevOps
Overview
Permissions in Azure DevOps control access to various resources and functionalities within your organization and projects. They help manage who can view, edit, and manage different aspects of your DevOps environment, ensuring security and compliance.
Key Concepts
- Security Groups: A collection of users that can be assigned permissions collectively. Azure DevOps has built-in groups (e.g., Project Administrators, Contributors, Readers) and allows you to create custom groups.
- Roles: Assign predefined roles to users or groups to simplify permission management.
- Inheritance: Permissions can be inherited from higher levels (e.g., organization, project) down to lower levels (e.g., repositories, pipelines).
Types of Permissions
1. Organization-Level Permissions
These permissions apply across the entire Azure DevOps organization.
- Access Level: Defines the level of access a user has (Basic, Stakeholder, Visual Studio subscriber, etc.).
- Billing: Manage billing and subscriptions.
- Extensions: Manage extensions and services at the organization level.
2. Project-Level Permissions
These permissions control access within a specific project.
- Project Administrators: Users can manage project settings and permissions.
- Contributors: Users can contribute code, create and manage work items, and modify pipelines.
- Readers: Users can view project content but cannot make changes.
3. Repository Permissions
These permissions control access to repositories within a project.
- Read: Allow users to read or clone the repository.
- Contribute: Allow users to push code to the repository.
- Manage permissions: Allow users to manage repository settings and permissions.
4. Pipeline Permissions
Permissions for managing build and release pipelines.
- Edit: Users can create, edit, and delete pipelines.
- Queue builds: Users can queue new builds.
- View builds: Users can view build logs and results.
5. Work Item Permissions
Permissions related to work item tracking.
- Create: Users can create work items.
- Edit: Users can edit work items.
- Delete: Users can delete work items.
Managing Permissions
Step 1: Access Project Settings
- Sign in to your Azure DevOps organization.
- Go to your project.
- In the lower-left corner, click on Project settings.
Step 2: Navigate to Permissions
- Under General, click on Permissions to view existing groups and permissions.
Step 3: Modify Permissions
- Select a Security Group: Choose a group (e.g., Project Administrators, Contributors) or create a new one.
- Adjust Permissions:
- For each permission type (e.g., Repositories, Pipelines), set the desired permission levels (Allow, Deny, Not set).
- Click Save Changes after adjusting permissions.
Step 4: Add Users to Security Groups
- In the Permissions section, click on the group you want to modify.
- Click on Members and then + Add to add users or groups to the selected security group.
Best Practices
- Follow the Principle of Least Privilege: Grant users the minimum permissions necessary to perform their roles effectively.
- Use Security Groups: Manage permissions through groups rather than individual users to simplify administration.
- Regularly Review Permissions: Periodically review permissions to ensure they are up to date and aligned with organizational policies.
- Document Permission Changes: Keep records of permission changes and access control to maintain compliance and audit trails.
Summary
Azure DevOps permissions provide a robust framework for managing access and control over resources within your organization and projects. By understanding and effectively managing permissions, you can enhance security, ensure compliance, and optimize collaboration across your development teams.
Azure DevOps Test Plans
Azure DevOps Test Plans is a service designed to help teams manage their testing efforts efficiently. It provides a suite of tools for planning, executing, and tracking tests throughout the development lifecycle.
Key Features of Azure Test Plans
- Test Case Management: Organize and manage test cases with detailed steps and expected outcomes.
- Manual Testing: Execute manual tests, record results, and log defects directly from the test runner.
- Automated Testing Integration: Support for integrating automated tests from various frameworks.
- Test Suites: Group test cases into test suites for organized testing.
- Rich Reporting and Analytics: Generate reports and dashboards to track quality metrics and test results.
Creating a Test Plan
Step 1: Navigate to Azure DevOps
- Open your Azure DevOps project.
- Click on Test Plans in the left-hand menu.
Step 2: Create a New Test Plan
- Click on New Test Plan.
- Enter a name and description for your test plan.
- Click Create.
Adding Test Suites
Step 1: Create a Test Suite
- In your test plan, click on New Suite.
- Choose between:
- Static Suite: A fixed set of test cases.
- Requirement-Based Suite: Linked to work items or requirements.
- Click Add to create the suite.
Creating Test Cases
Step 1: Define a Test Case
- In the test suite, click on New Test Case.
- Fill in the details:
- Title: Name of the test case.
- Steps: Detailed execution steps.
- Expected Result: Outcome of the test.
Step 2: Save the Test Case
- Click Save to store your test case.
Running Tests
Step 1: Execute Test Cases
- Select a test case and click Run.
- Perform the test and record results (e.g., Passed, Failed, Blocked).
Step 2: Logging Defects
If a test case fails:
- Click Add a bug in the test runner.
- Fill in the details and link it to the test case.
- Click Save to create the bug.
Viewing Test Results
- Go to the Test Plans tab to see the status of test cases.
- Review results and any associated bugs.
Integrating Automated Tests
Step 1: Set Up CI/CD
- Configure your CI/CD pipeline to run automated tests with your preferred framework (e.g., Selenium, NUnit).
- Ensure that the pipeline publishes test results.
Step 2: Monitor Test Results
- After the build completes, navigate to the Tests tab in the build summary.
- Review results and any linked defects.
Summary
Azure DevOps Test Plans streamlines the testing process, allowing teams to effectively manage manual and automated testing efforts. By leveraging its features, teams can ensure higher software quality and improved project outcomes.
Azure Kubernetes Service (AKS) Tutorial
Introduction to AKS
Azure Kubernetes Service (AKS) is a managed container orchestration service provided by Microsoft Azure. It simplifies the deployment, management, and operations of Kubernetes, making it easier to manage containerized applications.
Prerequisites
Before you start with AKS, ensure you have:
- An Azure account. You can create a free account here.
- The Azure CLI installed on your machine. You can download it here.
- Basic knowledge of Kubernetes concepts.
Step-by-Step Guide to Setting Up AKS
Step 1: Log in to Azure
Open your terminal or command prompt and log in to your Azure account:
az login
Step 2: Create a Resource Group
Create a resource group to hold your AKS cluster:
az group create --name myResourceGroup --location southcentralus
Step 3: Create an AKS Cluster
Create an AKS cluster with the following command. Adjust the parameters as needed:
az aks create --resource-group myResourceGroup --name myAKSCluster --node-count 1 --enable-addons monitoring --generate-ssh-keys
Step 4: Configure kubectl
Configure kubectl
, the command-line tool for Kubernetes:
az aks get-credentials --resource-group myResourceGroup --name myAKSCluster
Step 5: Verify the Cluster
Check that your AKS cluster is running:
kubectl get nodes
Step 6: Deploy an Application
Deploy a sample application, like Nginx:
kubectl create deployment nginx --image=nginx
Step 7: Expose the Application
Expose your Nginx deployment using a LoadBalancer service:
kubectl expose deployment nginx --port=80 --type=LoadBalancer
Step 8: Get the External IP Address
Retrieve the external IP address assigned to your service:
kubectl get services
Step 9: Scale the Application
Scale your application as needed:
kubectl scale deployment nginx --replicas=3
Step 10: Clean Up Resources
Delete the resource group and all associated resources when finished:
az group delete --name myResourceGroup --yes --no-wait
Best Practices for Using AKS
- Use Azure Monitor: Enable Azure Monitor for containers to gain insights into the performance and health of your applications.
- Implement RBAC: Use Role-Based Access Control (RBAC) for managing permissions within your Kubernetes cluster.
- Use Network Policies: Control traffic between pods for enhanced security.
- Monitor Costs: Keep track of your resource usage to manage costs effectively.
- Backup your Data: Implement backup and disaster recovery strategies for your applications and data.
Conclusion
Azure Kubernetes Service (AKS) provides a powerful and flexible platform for deploying and managing containerized applications. By following this guide, you can set up an AKS cluster and deploy a simple application. Explore further by implementing more complex scenarios and leveraging additional Azure services.
ARM Template Tutorial
Introduction
An Azure Resource Manager (ARM) template is a JSON file that defines resources for Azure to deploy. ARM templates help automate the provisioning of resources in a consistent and repeatable way.
Template Structure
An ARM template typically contains the following main sections:
$schema
: Specifies the schema for the template.contentVersion
: The version of the template (e.g., “1.0.0.0”).parameters
: Defines inputs for the template, like resource names and configurations.variables
: Holds reusable values within the template.resources
: Defines the resources to be deployed to Azure.outputs
: (Optional) Outputs information like resource IDs or endpoints after deployment.
Step 1: Define a Basic ARM Template
Below is an ARM template to deploy an Azure Storage Account.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountName": {
"type": "string",
"defaultValue": "mystorageaccount",
"metadata": {
"description": "Name of the storage account"
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for the storage account"
}
},
"sku": {
"type": "string",
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS",
"Standard_GRS",
"Standard_RAGRS",
"Standard_ZRS",
"Premium_LRS"
],
"metadata": {
"description": "Storage account SKU"
}
}
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2022-09-01",
"name": "[parameters('storageAccountName')]",
"location": "[parameters('location')]",
"sku": {
"name": "[parameters('sku')]"
},
"kind": "StorageV2",
"properties": {}
}
]
}
Deploy the Template
- Save the JSON above as azuredeploy.json.
- Open Azure CLI and run
az deployment group create --resource-group <YourResourceGroup> --template-file azuredeploy.json