databricks-cli installed, modules not visible - powershell

I installed the Databricks CLI, but I am unable to work with the library as such:
In powershell, I have set the working directory to: C:\Users\DNaught1\AppData\Local\Programs\Python\Python39\Scripts
I know the module is there:
Mode LastWriteTime Length Name
-a---- 13/10/2020 1:46 PM 74752 databricks.exe**
I then try to see the version but no luck as shown below:
PS C:\Users\DNaught1\AppData\Local\Programs\Python\Python39\Scripts> databricks --version
databricks : The term 'databricks' is not recognized as the name of a
cmdlet, function, script file, or operable program. Check the spelling
of the name, or if a path was included, verify that the path is
correct and try again. At line:1 char:1
databricks --version
+ CategoryInfo : ObjectNotFound: (databricks:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Suggestion [3,General]: The command databricks was not found, but does
exist in the current location. Windows PowerShell does not load
commands from the current location by default. If you trust this
command, instead type: ".\databricks". See "get-help
about_Command_Precedence" for more details.

I managed to work around it by using the following:
1- In Python use the command below to install the CLI module
package_names=['databricks-cli', 'requests'] #packages to install
pip.main(['install'] + package_names + ['--upgrade'])
2- In powershell cli:
change the context to the working directory:
Set-Location -Path C:\Users\DNaught1\AppData\Local\Programs\Python\Python39\Scripts
3 - Configure the databricks cli:
.\databricks.exe configure--token
.\databricks configure --token
Host: https://xxx.azuredatabricks.net
Token: dapi2b2dxxxxxxxxxa02c9e6866d322 - Access token for Secrets
4 - Write-host Configuration file for databricks access
Set-Content .databrickscfg "[DEFAULT]"
>> Add-Content .databrickscfg "host = https://xxx.azuredatabricks.net"
>> Add-Content .databrickscfg "token = dapi2b2dxxxxxxxxxa02c9e6866d322"
5 - Validate by checking file storage
.\dbfs ls

Related

Cannot Uninstall IoT Edge on Windows Server

I need to swap an IoT Edge device on Windows from one IoT Hub to another. I understand that current logic forces me to Uninstall IoT-Edge and install it again.
The problem is I get the following error trying to run this script:
{Invoke-WebRequest -useb aka.ms/iotedge-win} | Invoke-Expression; `
Uninstall-IoTEdge
I get this in return:
Invoke-Native : The term 'cmd' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1748 char:28
+ ... ersString = Invoke-Native "$dockerExe ps --all --format ""{{.ID}}""" ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (cmd:String) [Invoke-Native], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException,Invoke-Native
The Powershell is elevated as Admin. Am my missing some PATH variables? Any Ideas?
would you please run below commands in PowerShell window and share the results?
Get-Command "docker.exe"
Write-Host $env:ProgramFiles\iotedge-moby
check if the path exists or not.
do you know which version of iotedge service you installed? if the service is running, you can run "iotedge version" to find it out.
Thanks for the suggestion, but did manage to find workaround by removing docker with the help of this script:
https://success.docker.com/article/how-to-completely-remove-docker-in-windows-10
As fas as IOT Edge version it is 1.0.7 as 1.0.8. does not work in transparent gateway mode with Node-Red MQTT node (MS advised to wait for 1.0.9 where this bug will be fixed).

TFS 2017 build executing powershell failing due to term not recognized error on line 1

I'm pretty new to TFS and I'm still learning how to use it (so hopefully this isn't just a stupid oversight on my end). I'm working an internship this summer at a seasonal developer position, and essentially my end goal is to automate load testing for the company's website. I'm using TFS to achieve this goal; the build I currently have has two tasks only right now: one to start the controller and the testing environment, and one to stop them. My problem is that the build keeps failing before it really even starts, due to a "term not recognized" error on line 1, specifically caused by what appears to be the default working folder not being recognized.
Here are the relevant log files:
2019-05-30T20:00:02.0942883Z Executing the following powershell script. (workingFolder = D:\RM_agent\_work\11\s)
2019-05-30T20:00:02.0942883Z D:\RM_agent\_work\11\s
2019-05-30T20:00:02.4999117Z ##[error]. : The term 'D:\RM_agent\_work\11\s' is not recognized as the name of a
2019-05-30T20:00:02.4999117Z ##[error]cmdlet, function, script file, or operable program. Check the spelling of the
2019-05-30T20:00:02.4999117Z ##[error]name, or if a path was included, verify that the path is correct and try again.
2019-05-30T20:00:02.4999117Z ##[error]At line:1 char:3
2019-05-30T20:00:02.4999117Z ##[error]+ . 'D:\RM_agent\_work\11\s'
2019-05-30T20:00:02.4999117Z ##[error]+ ~~~~~~~~~~~~~~~~~~~~~~~~
2019-05-30T20:00:02.4999117Z ##[error] + CategoryInfo : ObjectNotFound: (D:\RM_agent\_work\11\s:String)
2019-05-30T20:00:02.4999117Z ##[error] [], CommandNotFoundException
2019-05-30T20:00:02.4999117Z ##[error] + FullyQualifiedErrorId : CommandNotFoundException
I know that the working folder defaults to $(Build.SourcesDirectory), so I'm assuming that D:\RM_agent\_work\11\s is what $(Build.SourcesDirectory) evaluates to. RM_agent is obviously an agent, so /_work/11/s should be the local path where it stores the source code. Why is it unrecognized then?
I tried manually setting the working folder for the scripts through tfs to the folder where the build is stored, but the build still failed and the logs still showed that workingFolder = D:\RM_agent\_work\11\s.
Additionally, the line of code that the build is failing on, Executing the following powershell script. (workingFolder = D:\RM_agent\_work\11\s), is nowhere in the script I am trying to execute, which confuses me. Where is this script coming from?
(I can remove this if it doesn't fit the guidelines/is off topic, but if anyone could point me towards any resources about tfs and/or load testing it would be massively helpful as well)
EDIT: Here is the powershell script for the first task
########################################
# start environment
########################################
# import modules
Import-Module '\\neenah-san1\TSbuild\Deployment\Tools\PowerShell\Azure\JJK.TS.Azure.psm1' -Force -Prefix 'TS'
# provide azure credentials
$credential = Get-Credential
# login to azure subscription
Login-AzureRmAccount -Credential $credential
# start the controller
Get-AzureRmVM -ResourceGroupName 'TS-LoadTest-TST' | Where-Object {$_.Name -match 'vstc'} | Start-TSAzureVM -Credential $credential
# wait for controller to fully start
Start-Sleep -Seconds 120
# start the agents
Get-AzureRmVM -ResourceGroupName 'TS-LoadTest-TST' | Where-Object {$_.Name -match 'vsta'} | Start-TSAzureVM -Credential $credential
# check status of all servers
Get-AzureRmVM -ResourceGroupName 'TS-LoadTest-TST' -Status | Sort-Object -Property Name | Select-Object -Property Name, PowerState | Format-Table -AutoSize
Solution structure:
EDIT 2: [RESOLVED] It's all fixed now, thank you! I went into the repository and mapped the folder my scripts were in directly to $(build.sourcesDirectory). Consequently I was able to change the file path to $(build.sourcesDirectory)\StartControllerAndAgents.ps1 and the build is now able to find the files to run.
You need to specify the path to the script as $(Build.SourcesDirectory)\Path\To\Script. Not the TFVC path which you've configured now $/Project/Path/To/Script.
The exact path depends on the workspace mapping of the build definition.
The same applies to the working directory.
There are a number of variables in Azure Pipelines (the current name for the Build hub in TFS/Azure DevOps) that resolve to different standardized paths on the agent. Almost all tasks take a relative path off of those variables.

how connect to Azure Machine Learning Web service using PowerShell?

To use Azure Machine Learning Web service here you can find some sample code in C#, R, Python and JavaScript. I want to use it in PowerShell.
I found this tutorial, but when I am running bellow line of code, it will return error that it is not recognized:
Set-AzureMLWebServiceConnection -URI $Url -APIKey $API_key
Output:
Set-AzureMLWebServiceConnection : The term 'Set-AzureMLWebServiceConnection' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\Reza\Desktop\ndbench\Azure\Automation\01_get_metrics\add_target_to_tables - runbook_01.ps1:33 char:1
+ Set-AzureMLWebServiceConnection -URI $Url -APIKey $API_key
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Set-AzureMLWebServiceConnection:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I can't found Set-AzureMLWebServiceConnection in my PowerShell command-list and I don't know how I can enable/install it.
Can you please guide me, how I can connect to Azure Machine Learning Web service using PowerShell?
The comment #gvee mentioned may be the best to use going forward though it is in beta.
However, to answer your question, use the Install-Module -Name AzureML command to get access to the Azure ML commands.

TFS build fails when running custom powershell script

I've added a Powershell script step to my on-premises TFS 2015 build definition. The script modifies assembly version in AssemblyInfo.cs file.
I tested the script with the Build Agent account in PowerShell ISE and it worked fine. However, the PowerShell step fails in TFS build with an access denied error.
The Build Agent account has full control permission to C:\agent\_work\11\s\source\MyProject\Properties folder.
Get-Content : Access to the path 'C:\agent_work\11\s\source\MyProject\Properties' is denied.
At C:\agent_work\11\s\source\MyProject\BuildScript\Update-AssembyInfoFile.ps1:64 char:10
+ (Get-Content $file) |
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (C:\agent_work...MyProject\Properties:String) [Get-Content], Unauthorized
AccessException
+ FullyQualifiedErrorId : GetContentReaderUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetContentCommand
The script error was caused by missing the file name in the file path. The message Access to the path 'C:\agent_work\11\s\source\MyProject\Properties' is denied is kind of confusing but it gives you idea that the file name is missing in the path. The path in the error message is a folder name rather than a filename. Hence, the error occurred.

Windows Server 2012R2 Core - can't run powershell DSC

After installing a fresh Windows Server 2012R2 Core installation I created a sample DSC to test and received: Term "Setup" is not recognized as a name ...
c:\src\dsc.ps1
Configuration Setup
{
Node .
{
WindowsFeature "IIS"
{
Ensure = "Present"
Name = "Web-Server"
}
}
}
C:\src> .\dsc.ps1
C:\src> Setup
Setup : The term 'Setup' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Setup
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (Setup:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
On my local Windows machine this works without any issues. Is there something I need to install or configure to make this work?
There is a small mistake in the line:
.\dsc.ps1
it should say
. .\dsc.ps1
to load the Setup configruation into the current session so you can use it.