How to install Azure CLI and Azure Functions Core Tools CLI with Homebrew

Verifying Homebrew

$ brew --version

Homebrew 3.2.6
Homebrew/homebrew-core (git revision c4d5aac8ec; last commit 2021-08-07)
Homebrew/homebrew-cask (git revision 1169dcb641; last commit 2021-08-07)

Demo repository is in the following link.

https://github.com/nodejs-projects-kenanhancer/serverless-azure-functions-typescript-demo

Azure CLI

Azure CLI, or Azure Command Line Interface, is a set of commands used to create and manage Azure resources. It is a cross-platform command-line tool that's available for Windows, macOS, and Linux and can be run in the Azure Cloud Shell directly from a web browser.

Azure CLI is designed to be easy to learn and get started with but powerful enough to manage your entire Azure environment. It's optimized for automation and can be used in a DevOps pipeline. You can use Azure CLI to create and manage resources such as virtual machines, storage accounts, and web apps, among others.

Before using Azure CLI, you need to authenticate with your Azure account. You can do this by using the az login command, which opens a web browser for you to sign in with your Azure credentials.

Azure CLI Usage Pattern

$ az [group] [subgroup] [command]

Example – to create a new resource group

$ az group create

Installing

$ brew update && brew install azure-cli

Verifying

$ az --version

azure-cli                         2.26.1 *

core                              2.26.1 *
telemetry                          1.0.6

Python location '/usr/local/Cellar/azure-cli/2.26.1/libexec/bin/python'
Extensions directory '/Users/kenanhancer/.azure/cliextensions'

Python (Darwin) 3.8.11 (default, Jun 29 2021, 03:08:07) 
[Clang 12.0.5 (clang-1205.0.22.9)]

Legal docs and information: aka.ms/AzureCliLegal


You have 2 updates available. Consider updating your CLI installation with 'az upgrade'

Please let us know how we are doing: https://aka.ms/azureclihats
and let us know if you're interested in trying out our newest features: https://aka.ms/CLIUXstudy

Upgrading

$ brew update && brew upgrade azure-cli

# OR

$ az upgrade

Uninstalling

$ brew uninstall azure-cli

Sign in with Azure CLI

Sign in interactively

$ az login

Sign in with device code flow interactively

If no web browser is available or the web browser fails to open, you may force device code flow with below command.

$ az login --use-device-code

Azure Functions Core Tools CLI

Here's what you can do directly with Azure Functions Core Tools CLI:

  • Create new function projects and functions.
  • Run and debug functions locally.
  • Deploy functions to Azure.

Azure Functions Core Tools lets you develop and test your functions on your local computer from the command prompt or terminal. Your local functions can connect to live Azure services, and you can debug your functions on your local computer using the full Functions runtime. You can even deploy a function app to your Azure subscription.

Prerequisites

The specific prerequisites for Core Tools depend on the features you plan to use:

  • One of the following tools for creating Azure resources:
  • Install extensions: To manually install extensions by using Azure Functions Core Tools, you must have the .NET 6.0 SDK installed. The .NET SDK is used by Core Tools to install extensions from NuGet. You don't need to know .NET to use Azure Functions extensions.

more information for Azure Functions Core Tools

Installing

$ brew tap azure/functions
$ brew install azure-functions-core-tools@4

# if upgrading on a machine that has 2.x or 3.x installed:
$ brew link --overwrite azure-functions-core-tools@4

Verifying

$ func --version

3.0.3477

Upgrading

$ brew upgrade azure-functions-core-tools@4

Uninstalling

$ brew uninstall azure-functions-core-tools@4