Friday, March 27, 2020

Quickstart: Sign up, sign in to Azure DevOps

Azure DevOps Services
In this quickstart, you learn how to sign up for Azure DevOps for free, sign in with a Microsoft or GitHub account, create an organization, create a project, and invite your teammates.
Sign up for Azure DevOps to upload and share code in free, unlimited private Git repositories.
Then, connect to your favorite development tool like Eclipse, Xcode, Visual Studio, IntelliJ, or Android Studio to work on apps anytime, anywhere.

Sign up with a personal Microsoft account

  1. Select the sign-up link for Azure DevOps.
  2. Enter your email address, phone number, or Skype ID for your Microsoft account. If you're a Visual Studio subscriber and you get Azure DevOps as a benefit, use the Microsoft account associated with your subscription. Select Next.
    Sign in with your Microsoft account
    If you don't have a Microsoft account, choose Create one. To learn more, see create a Microsoft account.
  3. Enter your password and select Sign in.
    Enter your password and sign in
  4. To get started with Azure DevOps, select Continue.
    Choose Continue to sign up for Azure DevOps
An organization is created based on the account you used to sign in. Sign in to your organization at any time, (https://dev.azure.com/{yourorganization}).
You can rename and delete your organization, or change the organization location. To learn more, see the following articles:
If you signed in with an existing Microsoft account, your next step is to Create a project. If you signed in with a newly created Microsoft account, then your project is automatically created and named after your account name. To learn more about managing projects, see Manage projects.

Sign up with a GitHub account

 Important
If your GitHub email address is associated with an Azure AD-backed organization in Azure DevOps, you can't sign in with your GitHub account, rather you must sign in with your Azure AD account.
  1. Select the sign-up link for Azure DevOpsStart free with GitHub. If you're already part of an Azure DevOps organization, select Sign in to Azure DevOps.
    Sign up for Azure DevOps
  2. Select Sign in with GitHub.
    Select Sign in with GitHub
    If you have an account in session already, select Use another account. You're taken to GitHub sign-in where you can enter your GitHub user name or email address.
  3. Enter your GitHub account credentials, and then select Sign in.
    Enter GitHub credentials
  4. Select Authorize Microsoft corporation.
    Authorize Microsoft
  5. To get started with Azure DevOps, select Continue.
    Choose Continue to sign up for Azure DevOps
An organization is created based on the account you used to sign in. Sign in to your organization at any time, (https://dev.azure.com/{yourorganization}).
You can rename and delete your organization, or change the organization location. To learn more, see Manage organizations.

Enable GitHub invitations

Creating a new Azure DevOps organization with your GitHub username turns on the Invite GitHub users policy by default. For existing organizations, your administrator can turn on this capability via Organization settings > Policies tab.
Once the setting is changed, sign out of Azure DevOps, and then from a fresh browser session, sign back in to the organization dev.azure.com/{organizationName} or organizationName.visualstudio.com with your GitHub credentials. You're now recognized as a GitHub user and the GitHub invitation experience is available to you.
Invite GitHub users policy
For more information about GitHub authentication, see FAQs.

Create a project

If you signed up for Azure DevOps with a newly created Microsoft account (MSA), your project is automatically created and named based on your sign-in.
If you signed up for Azure DevOps with an existing MSA or GitHub identity, you're automatically prompted to create a project. You can create either a public or private project. To learn more about public projects, see What is a public project?.
  1. Enter information into the form provided, which includes a project name, description, visibility selection, initial source control type, and work item process.
    Create project form ready for completion
  2. When your project is complete, the welcome page appears.
    Project creation confirmation dialog, new nav

Invite team members

Give team members access to your organization by adding their email addresses or GitHub usernames to your organization. For GitHub user invitations, ensure you've enabled the policy, Invite GitHub users in Organization settings > Policies tab.
  1. Sign in to your organization (https://dev.azure.com/{yourorganization}).
  2. Select Organization settings Organization settings.
    Open Organization settings
  3. Select Users > Add new users.
    Select Add users
  4. Enter the following information:
    • Users: Enter the email addresses (Microsoft accounts) or GitHub usernames for the users. You can add several email addresses by separating them with a semicolon (;). An email address appears in red when it's accepted.
    • Access level: Leave the access level as Basic for users who will contribute to the code base. To learn more, see About access levels.
    • Add to project: Select the project you want to add them to.
    • DevOps Groups: Leave as Project Contributors, the default security group for users who will contribute to your project. To learn more, see Default permissions and access assignments.
     Note
    Add email addresses for personal Microsoft accounts and IDs for GitHub accounts unless you plan to use Azure Active Directory (Azure AD) to authenticate users and control organization access. If a user doesn't have a Microsoft or GitHub account, ask the user to sign up for a Microsoft account or a GitHub account.
  5. When you're done, select Add to complete your invitation.

For more information about managing users and organization access, see Add organization users for Azure DevOps.

Design a CI/CD pipeline using Azure DevOps

This scenario provides architecture and design guidance for building a continuous integration (CI) and continuous deployment (CD) pipeline. In this example, the CI/CD pipeline deploys a two-tier .NET web application to the Azure App Service.
Migrating to modern CI/CD processes provides many benefits for application builds, deployments, testing, and monitoring. By using Azure DevOps along with other services such as App Service, organizations can focus on the development of their apps rather than the management of the supporting infrastructure.

Relevant use cases

Consider Azure DevOps and CI/CD processes for:
  • Accelerating application development and development lifecycles.
  • Building quality and consistency into an automated build and release process
  • Increasing application stability and uptime.

Architecture

Architecture diagram of the Azure components involved in a DevOps scenario using Azure DevOps and Azure App Service
The data flows through the scenario as follows:
  1. A developer changes application source code.
  2. Application code including the web.config file is committed to the source code repository in Azure Repos.
  3. Continuous integration triggers application build and unit tests using Azure Test Plans.
  4. Continuous deployment within Azure Pipelines triggers an automated deployment of application artifacts with environment-specific configuration values.
  5. The artifacts are deployed to Azure App Service.
  6. Azure Application Insights collects and analyzes health, performance, and usage data.
  7. Developers monitor and manage health, performance, and usage information.
  8. Backlog information is used to prioritize new features and bug fixes using Azure Boards.

Components

  • Azure DevOps is a service for managing your development lifecycle end-to-end—from planning and project management, to code management, and continuing to build and release.
  • Azure Web Apps is a PaaS service for hosting web applications, REST APIs, and mobile back ends. While this article focuses on .NET, there are several additional development platform options supported.
  • Application Insights is a first-party, extensible Application Performance Management (APM) service for web developers on multiple platforms.

Alternatives

While this article focuses on Azure DevOps, Azure DevOps Server (previously known as Team Foundation Server) could be used as an on-premises substitute. Alternatively, you could also use a set of technologies for an open-source development pipeline using Jenkins.
From an infrastructure-as-code perspective, Resource Manager templates were used as part of the Azure DevOps project, but you could consider other management technologies such as Terraform or Chef. If you prefer an infrastructure-as-a-service (IaaS)-based deployment and require configuration management, you could consider either Azure Automation State ConfigurationAnsible, or Chef.
You could consider these alternatives to hosting in Azure Web Apps:
  • Azure Virtual Machines handles workloads that require a high degree of control, or depend on OS components and services that are not possible with Web Apps (for example, the Windows GAC, or COM).
  • Service Fabric is a good option if the workload architecture is focused around distributed components that benefit from being deployed and run across a cluster with a high degree of control. Service Fabric can also be used to host containers.
  • Azure Functions provides an effective serverless approach if the workload architecture is centered around fine grained distributed components, requiring minimal dependencies, where individual components are only required to run on demand (not continuously) and orchestration of components is not required.
This decision tree for Azure compute services may help when choosing the right path to take for a migration.

Management and Security Considerations

  • Consider leveraging one of the tokenization tasks available in the VSTS marketplace.
  • Azure Key Vault tasks can download secrets from an Azure Key Vault into your release. You can then use those secrets as variables in your release definition, which avoids storing them in source control.
  • Use release variables in your release definitions to drive configuration changes of your environments. Release variables can be scoped to an entire release or a given environment. When using variables for secret information, ensure that you select the padlock icon.
  • Deployment gates should be used in your release pipeline. This lets you leverage monitoring data in association with external systems (for example, incident management or additional bespoke systems) to determine whether a release should be promoted.
  • Where manual intervention in a release pipeline is required, use the approvals functionality.
  • Consider using Application Insights and additional monitoring tools as early as possible in your release pipeline. Many organizations only begin monitoring in their production environment. By monitoring your other environments, you can identify bugs earlier in the development process and avoid issues in your production environment.

Deploy the scenario

Prerequisites

  • You must have an existing Azure account. If you don't have an Azure subscription, create a free account before you begin.
  • You must sign up for an Azure DevOps organization. For more information, see Quickstart: Create your organization.

Walk-through

Azure DevOps Projects will deploy an App Service Plan, App Service, and an App Insights resource for you, as well as configure an Azure Pipelines pipeline for you.
Once you've configure a pipeline with Azure DevOps Projects and the build is completed, review the associated code changes, work items, and test results. You will notice that no test results are displayed, because the code does not contain any tests to run.
The pipeline creates a release definition and a continuous deployment trigger, deploying our application into the Dev environment. As part of a continuous deployment process, you may see releases that span multiple environments. A release can span both infrastructure (using techniques such as infrastructure-as-code), and can also deploy the application packages required along with any post-configuration tasks.

Pricing

Azure DevOps costs depend on the number of users in your organization that require access, along with other factors like the number of concurrent build/releases required and number of test users. For more information, see Azure DevOps pricing.
This pricing calculator provides an estimate for running Azure DevOps with 20 users.
Azure DevOps is billed on a per-user per-month basis. There may be additional charges depending on concurrent pipelines needed, in addition to any additional test users or user basic licenses.
Review the following resources to learn more about CI/CD and Azure DevOps:

What is Azure DevOps?

Azure DevOps provides developer services to support teams to plan work, collaborate on code development, and build and deploy applications. Developers can work in the cloud using Azure DevOps Services or on-premises using Azure DevOps Server. Azure DevOps Server was formerly named Visual Studio Team Foundation Server (TFS).
Azure DevOps provides integrated features that you can access through your web browser or IDE client. You can use one or more of the following services based on your business needs:
  • Azure Repos provides Git repositories or Team Foundation Version Control (TFVC) for source control of your code
  • Azure Pipelines provides build and release services to support continuous integration and delivery of your apps
  • Azure Boards delivers a suite of Agile tools to support planning and tracking work, code defects, and issues using Kanban and Scrum methods
  • Azure Test Plans provides several tools to test your apps, including manual/exploratory testing and continuous testing
  • Azure Artifacts allows teams to share Maven, npm, and NuGet packages from public and private sources and integrate package sharing into your CI/CD pipelines

How to setup Visual Studio Code for Salesforce ?

Visual Studio Code is the latest IDE for Salesforce Development and in this blog post, I am going to tell you how you can setup Visual Studio Code for Salesforce Development. So, let's begin.

Download and Install VSCode

To download Visual Studio Code to your system, just go to:- https://code.visualstudio.com/ and you'll see an option to download VSCode for your system. I recommend you to download the stable build which is usually free from bugs, however, if you're keen to get the latest upcoming features before the world, you can download the insiders edition too.


Download and install VSCode in your system and on opening, you'll see the welcome screen as shown below:-

Download and Install Salesforce DX CLI

Now, as we've installed VSCode in our system, the next step is to install Salesforce DX CLI. To install that, go to:- https://developer.salesforce.com/tools/sfdxcli and you'll see the page as shown below from where you can download the salesforce dx cli and install the same on your system.


Once you have sfdx cli installed, you can test it by opening the command window and typing sfdx and then pressing enter you should get the result similar to the one given in the below image:-


Cool. You've now properly installed Salesforce DX CLI in your system. Let's get to the next step.

Install Salesforce Extension Pack

In order to make our IDE Salesforce ready. Salesforce has made it's own extension pack available for developers. Once you open your VSCode IDE you can click on the 4th icon on the left hand sidebar menu which is for managing extensions. Search for Salesforce Extension Pack and click on the first search result as shown in the below image:-


I've already installed that in my VSCode IDE so it's giving me the option to disable or uninstall it however you'll see a green button with install written on it as shown in the other search results in the image, just click on that button and it'll install the Salesforce Extension Pack for you. Salesforce Extension pack consists of a number of extensions, all of which are published by Salesforce. The extension pack has the following extensions as of now which will be activated automatically as you install this pack:-
  1. Salesforce CLI Integration
  2. Apex
  3. Visualforce
  4. Aura Components
  5. Apex Interactive Debugger
  6. Apex Replay Debugger
  7. Lightning Web Components
Many more extensions can be added to this extension pack in future as it's officially maintained by Salesforce.

Salesforce Package.xml Generator Extension for VS Code

This extension provides a User Interface to choose metadata components for Package.xml file for development against sandboxes or DE orgs (Org Development Model with VS Code). This is similar to Eclipse Force.com IDE Add/Remove Metadata Components option.

Prerequisites

Before you set up Salesforce Package.xml Generator Extension for VS Code, make sure that you have these essentials.
  • Salesforce Extensions for Visual Studio Code
  • Visual Studio Code v1.26 or later

Screenshots

Screenshot 1
Screenshot 2

How to use?

  • Setup your project using SFDX: Create Project with Manifest command and authorize it using SFDX: Authorize an Org command. Skip this step if already done. For more details refer [Org Development Model with VS Code] (https://forcedotcom.github.io/salesforcedx-vscode/articles/user-guide/org-development-model).
  • Open the command palette (press Ctrl+Shift+P on Windows or Linux, or Cmd+Shift+P on macOS) and run SFDX Package.xml Generator: Choose Metadata Components command.
  • In Choose Metadata Components for Package.xml page, select the Metadata you need and click on Update Package.xml button.
  • Package.xml file opens up with the selected metadata components.
  • Open the command palette (press Ctrl+Shift+P on Windows or Linux, or Cmd+Shift+P on macOS) and run SFDX: Retrieve Source in Manifest from Org
  • Select All button selects all the metadata components expect Reports, Dashboards, Email Templates and Documents.
  • If you don't want to modify the existing package.xml file & only want the generated xml content, click on Copy to Clipboard button. This copies the formatted package.xml contents to clipboard which can be pasted somewhere else.

Connecting with your Salesforce Org

Now, as you've installed Salesforce DX CLI, VS Code and all the required extensions, you're good to connect your IDE with your Salesforce Org. To do so, use command:- Ctrl + Shift + P or go to the View -> Command Palette and you'll see the command palette. Start writing:- Create Project with Manifest and press enter on the first option as shown below:-


In the next step, you need to enter the project name as shown below:-
Next, you need to select the location where you want the project to be created. Move to the desired location in the dialog box as shown below and click on Create Project


Your project will be created and you'll see the project structure in the left panel of VS Code which will be similar to the below image.


Now, we need to authorize an org. Press:- Ctrl + Shift + P and type Authorize an Org. Here, we're going to connect with our dev org or a sandbox instead of a dev hub or scratch org. You'll see the first option as:- Authorize an Org and press enter.

Next, we need to select the environment we need to connect to:-

You can connect to a sandbox or a production environment and even specify a custom url. Here, I am going to connect with my dev org which is a production environment for me. Just select your environment and press enter.

Now, we need to enter the org alias i.e. a familiar username for your org. I personally keep the same name which I have entered as the project name. In my case it's:- SFDCStopOrg. Just enter the alias as shown in the below image and press enter.


It'll automatically open your default browser and the login page where you can login with your org credentials. After logging in, Salesforce DX CLI will ask for the required permissions as shown in the below image, click Allow.


It'll give Salesforce DX CLI the required permissions and will open your org. Switch back to VS Code and you'll see a message similar to the below image:-

As shown in the above image, you may now close the browser. Now, we've successfully authorized our org. The next step is to get all our classes, triggers and other required files in our IDE. To do so, open package.xml from the manifest subfolder present in the left pane. Right click anywhere in package.xml and click the option:- SFDX: Retrieve Source in Manifest from Org as shown in the below image:-

It'll retrieve all the metadata from your org which is specified in your package.xml file. For more information on how to create your package.xml, you can refer to the official salesforce documentation here:- https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/manifest_samples.htm

Once, you've fetched all the data, you can see it under the force-app folder in the respective subfolders as shown below:-


We can open any class, lightning component, vf page or any other metadata by simply clicking on it and it'll show in the VS Code Editor as shown in the below image:-


You can do your changes and push the required changes to your org by right clicking and selecting:- SFDX: Deploy This Source to Org option. Similarly, to fetch the updated file from org to VS Code IDE, you can select SFDX: Retrieve This Source from Org. In order to get the whole org's refresh just move on to your package.xml, right click and select SFDX: Retrieve Source in Manifest from Org option.