I installed the Serverless Framework using the following NPM command
npm install -g serverless
When I try to run the serverless command sls in Powershell, I get a strange result which mentions "cmdlet Select-string".
sls --version
Can someone help me with this issue?
It seems that PowerShell has a command/cmdlet called Select-String which has an alias of sls. The PowerShell alias sls seems to take precedence over the node.js serverless command of sls.
One way to remove the PowerShell sls alias is by running the following in PowerShell
Remove-Item alias:sls
This change only applies to the current PowerShell session.
To permanently the sls PowerShell alias, you can change Microsoft.PowerShell_profile.ps1 file.
From PowerShell open your profile page in Notepad with the following command:
notepad $profile
Add the following to the file and save.
remove-item alias:sls
The profile can be reloaded by running the following from Powershell
. $profile
In my file, you will see that I have removed the aliases of curl and sls.
Now I see what I expect when entering sls in PowerShell.
How do I permanently remove a default Powershell alias?
--- Update ----
A more simple option is to use the command "serverless" instead of "sls".
For future visitors - in current version (if serverless is installed by npm/yarn) ^1.61 there is a secondary shortcut option:
slss
and that shortcut works flawlessly in Powershell. Imo it's the simplest way to avoid problems with Select-String alias collision and do not require any change in Powershell session or config.
PS C:\htdocs\serverless> slss -v
Framework Core: 1.61.1
Plugin: 3.2.7
SDK: 2.2.1
Components Core: 1.1.2
Components CLI: 1.4.0
If serverless is installed by chocolatey (as mentioned by #Nick Cox in comment) slss approach will fail, and you can use approach suggested by him - sls.exe
I was able to solve this issue by using Chocolaty.
Instead of npm install serverless use choco install serverless for windows,
Ref: https://www.serverless.com/framework/docs/getting-started/
Related
I used to use Remove-ServiceFabricNodeState to remove faulted Service Fabric nodes. with this cmdlet i was able to remove a specific node by its name.
However I'm unable to use this cmdlet any more. It is not allowing me to install the module using Install-Module ServiceFabric anymore saying the module cannot be found in the gallery.
Also I'm unable to find a similar cmdlet in iether Az.ServiceFabric or az cli. all that is available is a Remove-AzServiceFabricNode which cannot specify which node I want to remove. It just accepts an integer for how many nodes I want to remove.
I would like to know how can I remove a Node by its name?
To use Remove-ServiceFabricNodeState, just need to install the Azure Service Fabric SDK, it also includes the runtime and tools, after installing it, reopen a PowerShell session, you will be able to use the command.
Besides, you can also use the Azure Service Fabric CLI command sfctl node remove-state as mentioned in another reply, all depend on your requirement.
You can use Azure Service Fabric CLI with
sfctl node remove-state --node-name Node01 --timeout 60
This will remove the state of Node1 with a timeout of 60 seconds. Documnetation
For more information on how to install sfctl see how to install sfctl
Simple version:
Install Python (Version 3.X)
Install Pip
Execute the following command pip install -I sfctl==9.0.0. See table to see which version you need.
I'm using VS Code, and to get some intellisense when writing the azure cli script I've put everything in a .azcli file. My question now is how do I execute that file from a powershell terminal? Also, is it possible to use parameters in such a script like:
az servicebus topic create -g $resourceGroup -n $topicName --namespace-name $namespace
Is it possible to call a azcli file that looks like the one above and provice the $resourceGroup, $topicName, $namespace as argument from powershell?
I'm not aware of an easy way to do this in PowerShell. If someone knows, I would like to know as well.
If you have Windows Subsystem for Linux installed, you can run .azcli files just like .sh shell scripts inside WSL from PowerShell. WSL will need to have Azure CLI installed as well, so depending on the distribution you pick(Ubuntu or Debian are ussually safe), you will need to follow the instructions from Install the Azure CLI.
To run script in WSL from PowerShell terminal:
bash -c "./file.azcli"
Or directly in WSL terminal:
./file.azcli
You can use parameters in a .azcli file just like .sh shell scripts:
resourceGroup=MyRG
topicName=MyTopicName
namespace=myNameSpaceName
az servicebus topic create -g $resourceGroup -n $topicName --namespace-name $namespace
You could also create a .vscode/tasks.json, similar to what this GitHub issue recommends.
I am new in creating Kubernetes operators and found we can easily make one using the KUDO (Kubernetes Universal Declarative Operator) plugin. From the documentation, KUDO was installed using brew https://kudo.dev/docs/cli.html#setup-the-kudo-kubectl-plugin. Can anyone suggest a method to setup KUDO in linux without using linuxbrew-wrapper ?
Found a workaround to fix the kudo plugin in linux reducing the overhead of installing brew.
apt install linuxbrew-wrapper
brew install kudo-cli
First you figure out the corresponding package from the release page, which is compatible to your machine. Download and extract the file (my case : kudo_0.10.1_linux_x86_64.tar.gz) and there you can find the executable for kubectl-kudo.
Export the path :
export PATH=$PATH:/path/to/downloaded/executable/
You are almost done and can find the commands working. Try kubectl kudo version.
To make it permanent add this export line into your .bashrc and reload.
I installed a .NET global tool in Azure Cloud Shell (dotnet tool install -g). The installation works without reporting any problems.
After the installation the shell can’t find the tool (The term '{toolname}' is not recognized as the name of…).
Restarting the Cloud Shell shows no effect. I can see the tool with ‘dotnet tool list -g’. I can install and use the tool as local tool.
Is this a bug or a Cloud Shell restriction or am I missing something?
To answer my own question:
dotnet-tools doesn’t update the PATH environment variable like it does under Windows. I fixed this by adding the following line to my profile.ps1:
$Env:PATH += ":$HOME/.dotnet/tools"
profile.ps1 is located under $HOME/.config/PowerShell. If this is a new Cloud Shell installation, this file and folder must first be created.
The MSI file can be seen here: https://github.com/Azure/azure-powershell/releases/tag/v1.4.0-February2019
How can I install this file quietly through a script? (I am doing this inside a Docker container). The older AzureRM commandlets install fine (from the same GitHub repo, version 6.13.1 for example), but this one fails without any error.
I've tried installing with
msiexec.exe /i "D:\Azure-Cmdlets-6.13.1.24243-x64.msi" /qn
which works. But for Az,
msiexec.exe /i "D:\Az-Cmdlets-1.4.0.26146-x64.msi" /qn
doesn't work!
I'm installing it into a vanilla container without AzureRM present, so there shouldn't be any conflict.
I haven't tested this within a docker container yet, but the following command seems to be working on some VMs in my environment:
msiexec /i C:\temp\Az-Cmdlets-5.2.0.33762-x64.msi /QN /L*V "C:\temp\az.log" STARTAPP=1
I am doing some more tests to see if this will work on other machines. I will update my answer here if that STARTAPP=1 poses a problem and I need to find a better answer than this one.
I'm not sure why STARAPP=1 seems to work. I think it may have something to do with the way the package imports the other packages and it forces that to happen which then makes it work.