Command-line interface(CLI) for interacting with Azure Service Fabric clusters and their related entities.
sfctl is forward compatible with newer versions of Service Fabric runtime i.e. an older version of sfctl can work with newer versions of Service Fabric runtime but will not support new commands available in later versions. This also means that newer versions of sfctl will not be able to communicate with older versions of Service Fabric.
Following table gives the mapping of sfctl versions and Service Fabric runtime versions.
sfctl version | Service Fabric runtime version |
---|---|
1.1.0 | 5.6.130 or later |
2.0.0 | 6.0 and later |
Python 3.6 or later installed on the machine.
pip commands to Install, Upgrade and Uninstall to a central location on the machine require running commands from an admin Command prompt (Windows) or a Terminal window with sudo access (Linux or Mac). On Linux or Mac, prepend sudo to each of these commands below.
pip3 install sfctl
Identify the the most appropriate version from table above and specify it in the following command
pip3 install sfctl==replace-with-required-version
Following will install version 1.1.0 of sfctl
pip3 install sfctl==1.1.0
pip3 show sfctl
pip3 install -U sfctl
pip3 install -U sfctl==replace-with-required-version
pip uninstall -y sfctl
There may be a need to install different versions of sfctl side by side to interact with clusters running different versions of Service Fabric runtime.
pipenv package can be used to setup a python virtual environment that can be used to install a different version of sfctl separate from the globally installed version.
-
Install pipenv.
NOTE: Only this command requires an admin command prompt or sudo access. Do not use admin command prompt or sudo for rest of the commands below
pip3 install pipenv
-
Create a directory for installing files for virtual environment (commands below installs sfctl 1.1.0)
mkdir sfctl-1.1.0
-
Install sfctl in virtual env
pipenv --three install sfctl-1.1.0
-
Create a shell that uses files in virtual environment
pipenv --three shell
-
Run 1.1.0 of sfctl
pip show sfctl sfctl --help
-
Exit virtual environment shell
exit
-
Run globally installed version of sfctl
pip show sfctl sfctl --help
sfctl github repo has Dockerfile to generate a container with the required version of sfctl.
-
Install Docker CE the machine.
-
Clone sfctl repo using information on the github page - https://github.com/Azure/service-fabric-cli
-
Open a Command Prompt (Windows) or Terminal window (Linux or Mac) and navigate to the Dockerfiles folder under the root of the enlistment
pushd path-to-root-of-enlistment/Dockerfiles
-
Build the docker image
Windows
REM replace 2.0.0 with required version docker build -t sfctl_2.0.0 -f Dockerfile.windows --build-arg sfctl_version=2.0.0 .
Linux
# replace 2.0.0 with required version docker build -t sfctl_2.0.0 -f Dockerfile.linux --build-arg sfctl_version=2.0.0 .
-
Start the container in interactive mode. Replace the name of the name of the image with the image for the required version
docker run -it sfctl_2.0.0
-
Once the container starts at the container command prompt run sfctl
sfctl -h ...
-
Exit the container
exit
sfctl has extensive help for command line options and commands. --help option gives detailed information
Output from sfctl 2.0.0
sfctl --help
Group
sfctl : Commands for managing Service Fabric clusters and entities. This version is compatible
with Service Fabric 6.0 runtime.
Commands follow the noun-verb pattern. See subgroups for more information.
Subgroups:
application: Create, delete, and manage applications and application types.
chaos : Start, stop and report on the chaos test service.
cluster : Select, manage and operate Service Fabric clusters.
compose : Create, delete and manage Docker Compose applications.
is : Query and send commands to the infrastructure service.
node : Manage the nodes that form a cluster.
partition : Query and manage partitions for any service.
replica : Manage the replicas that belong to service partitions.
rpm : Query and send commands to the repair manager service.
sa-cluster : Manage stand-alone Service Fabric clusters.
service : Create, delete and manage service, service types and service packages.
store : Perform basic file level operations on the cluster image store.
sfctl cluster select --help
Command
sfctl cluster select: Connects to a Service Fabric cluster endpoint.
If connecting to secure cluster specify a cert (.crt) and key file (.key) or a single file
with both (.pem). Do not specify both. Optionally, if connecting to a secure cluster,
specify also a path to a CA bundle file or directory of trusted CA certs.
Arguments
--endpoint [Required]: Cluster endpoint URL, including port and HTTP or HTTPS prefix.
--aad : Use Azure Active Directory for authentication.
--ca : Path to CA certs directory to treat as valid or CA bundle file.
--cert : Path to a client certificate file.
--key : Path to client certificate key file.
--no-verify : Disable verification for certificates when using HTTPS, note: this is an
insecure option and should not be used for production environments.
--pem : Path to client certificate, as a .pem file.
Global Arguments
--debug : Increase logging verbosity to show all debug logs.
--help -h : Show this help message and exit.
--output -o : Output format. Allowed values: json, jsonc, table, tsv. Default: json.
--query : JMESPath query string. See http://jmespath.org/ for more information and
examples.
--verbose : Increase logging verbosity. Use --debug for full debug logs.
See the corresponding Wiki for more information.
This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.