Issue to use SSH with VSCODE & windows server - vscode-remote

I try to use the remote-ssh for windows on vscode but the installation on the server failed.
The server it's a windows server 2022
I spend time on internet to find a way but it's was a failure.
server.cmd' --start-server --host=127.0.0.1 --enable-remote-auto-shutdown --port=0 --connection-secret
[11:00:34.015] >
[11:00:38.215] > Server did not start successfully. Full server log at C:\Users\XXXX\.vscode-server\.97dec172d3256f8ca4bfb2143f3f76b503ca0534.log >>>
> C:\Users\XXXX\.vscode-server\bin\97dec172d3256f8ca4bfb2143f3f76b503ca0534\server.cmd :
> server.sh is being replaced by 'bin/code-server'. Please migrate to the new command and adopt the
> following new default behaviors:
> At line:1 char:1
> + C:\Users\XXXX\.vscode-server\bin\97dec172d3256f8ca4bfb2143f3f76b ...
> + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[11:00:38.222] >
> + CategoryInfo : NotSpecified: (server.sh is be...ault behaviors::String) [], RemoteE
> xception
> + FullyQualifiedErrorId : NativeCommandError
>
Anyone have a solution for that ?
Kr
Jerry
use vscode with ssh

Related

Powershell Script to Edit IIS File Extensions

Curious if someone could point me in the direction to how I could automate IIS Request Filtering File Extensions? I have used the following per Microsoft manuals, but when the extension is already set to false I get an error. Even though the manual states that changing the value from false to true will enable. Am I missing something very simple?
https://learn.microsoft.com/en-us/iis/configuration/system.webserver/security/requestfiltering/fileextensions/
Start-IISCommitDelay
$fileExtensions = Get-IISConfigSection -CommitPath 'Default Web Site' -SectionPath 'system.webServer/security/requestFiltering' | Get-IISConfigCollection -CollectionName 'fileExtensions'
New-IISConfigCollectionElement -ConfigCollection $fileExtensions -ConfigAttribute #{ 'fileExtension' = '.asax'; 'allowed' = $true } -AddAt 0
Set-IISConfigAttributeValue -ConfigElement $fileExtensions -AttributeName 'applyToWebDAV' -AttributeValue $true
Stop-IISCommitDelay
New-IISConfigCollectionElement : Filename:
Error: Cannot add duplicate collection entry of type 'add' with unique key
attribute 'fileExtension' set to '.asax'
At line:5 char:1
+ New-IISConfigCollectionElement -ConfigCollection $fileExtensions -Con ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-IISConfigCollectionElemen
t], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Micr
osoft.IIS.Powershell.Commands.NewIISConfigCollectionElementCommand
Set-IISConfigAttributeValue : Object reference not set to an instance of an
object.
At line:7 char:1
+ Set-IISConfigAttributeValue -ConfigElement $fileExtensions -Attribute ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-IISConfigAttributeValue],
NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException,Microsoft.IIS.Powe
rshell.Commands.SetIISConfigAttributeValueCommand
WARNING: No active transaction.
Never able to figure out why this process doesn't work as it should per the man docs from Microsoft, but found the configuration files for IIS and made an edited version and wrote a Powershell to move the original and place the edited version in the needed directories. Problem solved.

VSCode Insiders Remote SSH stopped working

I'm using Visual Studio Code Insiders version 1.65.0-insider. Until 3 days ago, I was not having any problem connecting to the remote server at work from my work laptop through a VPN. I have my ssh config file and when I opened vscode (when connected to the VPN), I was asked for my password and it connected without problems.
However, from yesterday I have started getting an error stating Could not establish connection to idk4v: The VS Code Server failed to start. idk4v is the remote machine's name that I gave in my ssh config file. I also get Waiting for server log... in the output continuously. I am pasting the output here from trying out just now. I have removed the non-essential parts for brevity:
[08:27:13.110] Log Level: 2
[08:27:13.113] remote-ssh#0.70.0
[08:27:13.113] win32 x64
[08:27:13.114] SSH Resolver called for "ssh-remote+idk4v", attempt 1
[08:27:13.114] "remote.SSH.useLocalServer": false
[08:27:13.114] "remote.SSH.showLoginTerminal": false
[08:27:13.114] "remote.SSH.remotePlatform": {"idk4l":"linux","idk4v":"linux"}
[08:27:13.114] "remote.SSH.path": undefined
[08:27:13.115] "remote.SSH.configFile": undefined
[08:27:13.115] "remote.SSH.useFlock": true
[08:27:13.115] "remote.SSH.lockfilesInTmp": false
[08:27:13.115] "remote.SSH.localServerDownload": auto
[08:27:13.115] "remote.SSH.remoteServerListenOnSocket": false
[08:27:13.115] "remote.SSH.showLoginTerminal": false
[08:27:13.115] "remote.SSH.defaultExtensions": []
[08:27:13.115] "remote.SSH.loglevel": 2
[08:27:13.115] "remote.SSH.serverPickPortsFromRange": {}
[08:27:13.115] "remote.SSH.enableDynamicForwarding": true
[08:27:13.115] "remote.SSH.serverInstallPath": {}
[08:27:13.116] SSH Resolver called for host: idk4v
[08:27:13.116] Setting up SSH remote "idk4v"
[08:27:13.128] Using commit id "50089c3f92c17584a4aca179f51f220b56c22020" and quality "insider" for server
[08:27:13.130] Install and start server if needed
[08:27:13.132] Checking ssh with "ssh -V"
[08:27:13.159] > OpenSSH_for_Windo
[08:27:13.159] > ws_8.1p1, LibreSSL 3.0.2
[08:27:13.162] Running script with connection command: ssh -T -D 51608 idk4v bash
[08:27:13.163] Terminal shell path: C:\windows\System32\cmd.exe
[08:27:13.361] > ]0;C:\windows\System32\cmd.exe
[08:27:13.362] Got some output, clearing connection timeout
[08:27:17.073] >
>
[08:27:24.396] Showing password prompt
[08:27:27.658] Got password response
[08:27:27.658] "install" wrote data to terminal: "********"
[08:27:27.677] >
[08:27:28.215] > 796e33571197: running
[08:27:28.272] > Acquiring lock on /home/su0/.vscode-server-insiders/bin/50089c3f92c17584a4aca179f51f220b56c22020/vscode-remote-lock.su0.50089c3f92c17584a4aca179f51f220b56c22020
[08:27:28.296] > Found existing installation at /home/su0/.vscode-server-insiders/bin/50089c3f92c17584a4aca179f51f220b56c22020...
> Checking /home/su0/.vscode-server-insiders/.50089c3f92c17584a4aca179f51f220b56c22020.log and /home/su0/.vscode-server-insiders/.50089c3f92c17584a4aca179f51f220b56c22020.pid for a running server
[08:27:28.306] > Looking for server with pid: 294423
[08:27:28.413] > Starting server with command... /home/su0/.vscode-server-insiders/bin/50089c3f92c17584a4aca179f51f220b56c22020/server.sh --start-server --host=127.0.0.1 --enable-remote-auto-shutdown --port=0 &> "/home/su0/.vscode-server-insiders/.50089c3f92c17584a4aca179
> f51f220b56c22020.log" < /dev/null
> printenv:
[08:27:28.431] > XDG_SESSION_ID=219
> SELINUX_ROLE_REQUESTED=
> SHELL=/bin/zsh
> SSH_CLIENT=10.159.165.35 51610 22
> SELINUX_USE_CURRENT_RANGE=
> USER=su0
> VSCODE_AGENT_FOLDER=/home/su0/.vscode-server-insiders
> MAIL=/var/mail/su0
> PATH=/usr/local/bin:/usr/bin
> PWD=/home/su0
> SELINUX_LEVEL_REQUESTED=
> SHLVL=1
> HOME=/home/su0
> LOGNAME=su0
> SSH_CONNECTION=10.159.165.35 51610 10.1.164.50 22
> XDG_RUNTIME_DIR=/run/user/46546
> _=/usr/bin/printenv
> Spawned remote server: 6344
> Waiting for server log...
Waiting for server log...
[08:27:36.044] >
> *
> * Reminder: You may only use this software with Visual Studio family products,
> * as described in the license (https://go.microsoft.com/fwlink/?linkid=2077057)
> *
>
[08:27:36.055] >
> Server did not start successfully. Full server log at /home/su0/.vscode-server-insiders/.50089c3f92c17584a4aca179f51f220b56c22020.log >>>
> server.sh is being replaced by 'bin/code-server-insiders'. Please migrate to the new command and adopt the following new default behaviors:
> * connection token is mandatory unless --without-connection-token is used
> * host defaults to `localhost`
> *
> * Visual Studio Code Server
> *
> * By using the software, you agree to
> * the Visual Studio Code Server License Terms (https://aka.ms/vscode-server-license) and
> * the Microsoft Privacy Statement (https://privacy.microsoft.com/en-US/privacystatement).
> *
> Do you accept the terms in the License Agreement?<<< End of server log
> 796e33571197: start
> exitCode==32==
> listeningOn====
> osReleaseId==centos==
> arch==x86_64==
> tmpDir==/run/user/46546==
> platform==linux==
> unpackResult====
> didLocalDownload==0==
> downloadTime====
> installTime====
> extInstallTime====
> serverStartTime==7623==
> 796e33571197: end
[08:27:36.055] Received install output:
exitCode==32==
listeningOn====
osReleaseId==centos==
arch==x86_64==
tmpDir==/run/user/46546==
platform==linux==
unpackResult====
didLocalDownload==0==
downloadTime====
installTime====
extInstallTime====
serverStartTime==7623==
[08:27:36.056] Resolver error: Error: The VS Code Server failed to start
at Function.ServerInstallError (c:\Users\su0\.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.70.0\out\extension.js:1:430359)
at u (c:\Users\su0\.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.70.0\out\extension.js:1:424682)
at Object.t.handleInstallOutput (c:\Users\su0\.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.70.0\out\extension.js:1:429101)
at Object.t.tryInstall (c:\Users\su0\.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.70.0\out\extension.js:1:524212)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async c:\Users\su0\.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.70.0\out\extension.js:1:487216
at async Object.t.withShowDetailsEvent (c:\Users\su0\.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.70.0\out\extension.js:1:490561)
at async Object.t.resolve (c:\Users\su0\.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.70.0\out\extension.js:1:488295)
at async c:\Users\su0\.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.70.0\out\extension.js:1:564197
[08:27:36.060] ------
[08:27:36.285] >
[08:27:37.355] "install" terminal command done
[08:27:37.355] Install terminal quit with output:
I tried this solution, where I both killed and uninstalled the VS Code Server on the host, deleted the ~/.vscode-server-insiders directory on the remote server, restarted VS Code, and tried to reconnect to the server. But I got the same error. I couldn't find any other solution. Any help is appreciated.
This is very much a hack and absolutely not a long term solution but as a quick work around.
Find the server.sh path in the log you posted, open it in an editor, and add --accept-server-license-terms to the last line so it looks something like "$ROOT/node" ${INSPECT:-} "$ROOT/out/server-main.js" --compatibility=1.63 --accept-server-license-terms "$#". This will accept the terms automatically until this gets patched by MS.
on Windows check
C:\Users\yourusername.vscode-cli\license_consent.json
for
{"consented":true}
I had the same type of problem connecting to remote servers with the waiting for server log. I found the post here, and as was working on repeated tries, I notice my C:\Users\myid.vscode-cli\license_consent.json just showed up 2/18/2023 7:57 PM PST. Now, I can assess. Not sure why it finally showed up.

PowerShell & SQL Server : Attempt to retrieve data for object failed for ManagedComputer

I'm currently writing a script to install a new SQL Server instance with PowerShell.
In this script, after the instance has been created, I disable the dynamic port and give it a new fixed port.
Import-Module SqlPs
[...] # Install a new instance SQL Server
$wmi = (Get-Item "SQLServer:\SQL\$Env:ComputerName").ManagedComputer
$urn = "ManagedComputer[#Name='$Env:ComputerName']/ ServerInstance[#Name='$Instance']/ ServerProtocol[#Name='Tcp']"
$tcp = $wmi.GetSmoObject($urn)
$tcp.IPAddresses['IPAll'].IPAddressProperties['TcpPort'].Value = "$Port"
$tcp.IPAddresses['IPAll'].IPAddressProperties['TcpDynamicPorts'].Value = ""
$tcp.Alter()
This script works correctly but when I try to run it a second times on the same PowerShell window, it return the following error :
Exception calling "GetSmoObject" with "1" argument(s): "Attempt to retrieve data for object failed for ManagedComputer 'MYSERVER'."
At .\New-Instance.ps1:316 char:5
+ $tcp = $wmi.GetSmoObject($urn)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FailedOperationException
$Error[0] | Format-List -Force
Exception : System.Management.Automation.MethodInvocationException: Exception calling "GetSmoObject" with "1" argument(s): "Attempt to retrieve data for object failed for ManagedComputer 'MYSERVER'." --->
Microsoft.SqlServer.Management.Smo.FailedOperationException: Attempt to retrieve data for object failed for ManagedComputer 'MYSERVER'. ---> Microsoft.SqlServer.Management.Smo.MissingObjectException: The
ServerInstance 'MYINSTANCE' does not exist on the server.
at Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer.GetSmoObjectRec(Urn urn)
at Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer.GetSmoObjectRec(Urn urn)
at Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer.GetSmoObject(Urn urn)
--- End of inner exception stack trace ---
at Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer.GetSmoObject(Urn urn)
at CallSite.Target(Closure , CallSite , Object , Object )
--- End of inner exception stack trace ---
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
TargetObject :
CategoryInfo : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : FailedOperationException
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, D:\SqlServer\Scripts\New-Instance.ps1: line 316
at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}
PSMessageDetails :
Yet, the instance 'MYINSTANCE' has been installed successfully. I think the recovered ManagedComputer hasn't been update and doesn't include the new instance 'MYINSTANCE'.
How can I force the refresh of the recovered ManagedComputer ?
My PowerShell Version :
$PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 1 14393 3471

Issues with EPiServer.TinyMCESpellChecker / NHunspell

During a reinstallation of the EPiServer.TinyMCESpellChecker package, I was having problems with the NHunspell dependency. Trying out the SpellChecker would show a browser alert message with the HTML of an error page on it, with the message that it was unable to find NHunspellx86.DLL. I checked my bin/ folder, and indeed the DLL was missing. What was stranger was that it was present in the nuget packages/ folder for the NHunspell install.
Here is the error message that showed when I reinstalled NHunspell in particular:
PM> update-package -reinstall nhunspell
Attempting to gather dependency information for multiple packages with respect to project 'Guthrie.Web', targeting '.NETFramework,Version=v4.6.2'
Gathering dependency information took 7.41 sec
Attempting to resolve dependencies for multiple packages.
Resolving dependency information took 0 ms
Resolving actions install multiple packages
Retrieving package 'NHunspell 1.2.5554.16953' from 'nuget.org'.
Removed package 'NHunspell 1.2.5554.16953' from 'packages.config'
Successfully uninstalled 'NHunspell 1.2.5554.16953' from Guthrie.Web
Package 'NHunspell.1.2.5554.16953' already exists in folder 'C:\TFS2013\ClientGITCollection\Guthrie\GuthrieEpi\packages'
'Hunspellx86.dll' already exists. Skipping...
'Hunspellx64.dll' already exists. Skipping...
Added package 'NHunspell.1.2.5554.16953' to 'packages.config'
Executing script file 'C:\TFS2013\ClientGITCollection\Guthrie\GuthrieEpi\packages\NHunspell.1.2.5554.16953\tools\install.ps1'
Value does not fall within the expected range.
At C:\TFS2013\ClientGITCollection\Guthrie\GuthrieEpi\packages\NHunspell.1.2.5554.16953\tools\install.ps1:4 char:1
+ $hunspellx86Dll = $project.ProjectItems.Item("Hunspellx86.dll")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException
You cannot call a method on a null-valued expression.
At C:\TFS2013\ClientGITCollection\Guthrie\GuthrieEpi\packages\NHunspell.1.2.5554.16953\tools\install.ps1:5 char:1
+ $hunspellx86Dll.Properties.Item("BuildAction").Value = 0 # BuildActio ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\TFS2013\ClientGITCollection\Guthrie\GuthrieEpi\packages\NHunspell.1.2.5554.16953\tools\install.ps1:6 char:1
+ $hunspellx86Dll.Properties.Item("CopyToOutputDirectory").Value = 2 # ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Value does not fall within the expected range.
At C:\TFS2013\ClientGITCollection\Guthrie\GuthrieEpi\packages\NHunspell.1.2.5554.16953\tools\install.ps1:10 char:1
+ $hunspellx64Dll = $project.ProjectItems.Item("Hunspellx64.dll")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException
You cannot call a method on a null-valued expression.
At C:\TFS2013\ClientGITCollection\Guthrie\GuthrieEpi\packages\NHunspell.1.2.5554.16953\tools\install.ps1:11 char:1
+ $hunspellx64Dll.Properties.Item("BuildAction").Value = 0 # BuildActio ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\TFS2013\ClientGITCollection\Guthrie\GuthrieEpi\packages\NHunspell.1.2.5554.16953\tools\install.ps1:12 char:1
+ $hunspellx64Dll.Properties.Item("CopyToOutputDirectory").Value = 2 # ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Successfully installed 'NHunspell 1.2.5554.16953' to Guthrie.Web
As it turns out, the error message was appearing because the NHunspellx86 and NHunspellx64 DLLs are in the content folder of the nuget package. What this means is that if the file is present in your solution, it does not get overwritten. In order to resolve the error, I had to force uninstall NHunspell (force because I wanted nuget to ignore that the EPiServer spellchecker depended on it):
uninstall-package nhunspell -Force
and then delete the NHunspellx86 and NHunspellx64 DLL's in the root of my website project. Turns out, the original installation of EPiServer.TinyMCESpellChecker had put them there, and the fact that they existed was preventing nuget from reinstalling the package correctly by copying over the DLL's from the content tab. After you've deleted both DLL's, run the following:
install-package nhunspell
Now the console should show NHunspell installing without errors, and when your run EPiServer again, the TinyMCESpellchecker should work without errors!

Azure Powershell SQL DataBase Export to Storage Container gets "An Error Occurred while Sending the Request"

I'd appreciate any help, even if it's just to suggest a way to diagnose the situation. The error message isn't really helping.
I've built a new VM from which I'm running PowerShell scripts to backup my databases. It had worked before on an old server for several months, and worked once on the new server, then I upgraded my Azure PowerShell cmdlets, and haven't been able to get it to work again. Mostly it says "An Error Occurred while sending the request", although twice it's said "Error Copying Content to a Stream" instead.
Below is my source code, with sensitive stuff replaced with ?'s. When I display the $stctx and $dbctx, they seem to have reasonable values. I added the IP address of the server as an exception to the db firewall, and I've installed SQL Server Management Studio and verified that I can connect to the database.
Here are the two error messages that I get:
Start-AzureSqlDatabaseExport : An error occurred while sending the request.
At C:\Users\Public\PublicCmds\test.ps1:29 char:1
+ Start-AzureSqlDatabaseExport -SqlConnectionContext $dbctx -StorageContext $stctx ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Start-AzureSqlDatabaseExport],
HttpRequestException
+ FullyQualifiedErrorId :
Microsoft.WindowsAzure.Commands.SqlDatabase.Database.Cmdlet.StartAzureSqlDatabaseExport
Start-AzureSqlDatabaseExport : Error while copying content to a stream.
At C:\Users\Public\PublicCmds\test.ps1:29 char:1
+ Start-AzureSqlDatabaseExport -SqlConnectionContext $dbctx -StorageContext $stctx ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Start-AzureSqlDatabaseExport], HttpRequestException
+ FullyQualifiedErrorId :
Microsoft.WindowsAzure.Commands.SqlDatabase.Database.Cmdlet.StartAzureSqlDatabaseExport
Here is a sanitized version of the source code:
param($dbname)
if ($dbname -eq $null) {
write-host "Database code must be specified"
return
}
$password = "????????" | ConvertTo-SecureString -asPlainText -Force
$servercredential = new-object System.Management.Automation.PSCredential("????", $password)
$dbsize = 1
$dbrestorewait = 10
$dbserver = "????"
$stacct = $dbcode
$stkey = "????????"
$stctx = New-AzureStorageContext -StorageAccountName $stacct -StorageAccountKey $stkey
$dbctx = New-AzureSqlDatabaseServerContext -ServerName $dbserver -Credential $servercredential
$dt = Get-Date
$timestamp = "_" + $dt.Year + "-" + ("{0:D2}" -f $dt.Month) + "-" + ("{0:D2}" -f $dt.Day) + "-" + ("{0:D2}" -f $dt.Hour) + ("{0:D2}" -f $dt.Minute)
$bkupname = $dbname + $timestamp + ".bacpac"
write-host "db context"
$dbctx
write-host "storage context"
$stctx
write-host "Backup $dbname to $bkupname"
Start-AzureSqlDatabaseExport -SqlConnectionContext $dbctx -StorageContext $stctx - StorageContainerName databasebackup -DatabaseName $dbname -BlobName $bkupname
I made two changes that together fixed the problem:
- There was an error in the filename (wish the error message said as much)
- I changed to using AD security (the free kind)

Resources