Azure Cosmos DB Emulator on Docker

Microsoft instructions were fairly ok.

https://docs.microsoft.com/en-us/azure/cosmos-db/local-emulator#running-on-docker

Couple of gotchas:

The output is quite different to the documentation.

  • It suggests the directory is C:\CosmosDB.Emulator\bind-mount
    It is actually at %localappdata%CosmosDBEmulator\bind-mount

The log was useful. The Data Explorer is available at the last endpoint in the log. For me it was http://<AnIP&gt;:8081/

Power BI Notes

General

 

 

 

Power BI – Templates – Also transferring PBI without data

Thanks to SQL Bristol Meetup Tue-20-Nov

 

Power BI Design Strategies

  1. Templates as good part of design strategy

 

Transfer Power BI without data

Was looking for a method to transfer a Power BI model between remote computers.

From the above talk, saving a Power BI as a template, strips all the data away and the file becomes much smaller.

The template may then be transferred to another machine.
Also, have put the template in Git source control – as it no longer contains data.

When the template is opened, it creates a new document and immediately reconnects to data sources and loads the data. The file may then be saved locally

 

 

Run SQL Server with Docker

 

Why

    1. Developer machines
      On my developer machines I have installed various version of SQL Server. These run services in the background and are difficult to stop and uninstall.Containers offer the opportunity to install then destroy and start again.
    2. Development and Testing
      Store images/containers and then recreate
    3. Future: create images which derive from base images and store and share in a repository possibly in Azure Container Registry

Get Started:

Install docker for windows

https://docs.docker.com/docker-for-windows/install/

Turn on virtualisation
Hyper-V
Docker

Quickstart: Run SQL Server container images with Docker

https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker?view=sql-server-2017

Note on using PowerShell

Some docker commands do not work inside the ISE.
For those, or all commands use PowerShell console window

Connect from outside the container

From SqlCmd or SSMS

Use the IP address of the machine that hosts your container (probably your machine)
e.g. 10.0.0.21,1433

The function inspect gives information about the container, but not the host IP:
docker inspect

docker inspect –format ‘{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}’ <container id>

 

 

Restore a database into the image

Now, we have SQL running in docker, it would be useful to restore a database into that.

  1. Outside Docker
    Backup database
    Tip: SSMS backup in UI, but then “Script action to new query window” and store it
  2. Copy file into the running image
    Use Bash
    docker exec -it sql1 “bash”Then Linux commands to make directory
    Exit Bash
    docker cp MyDatabase.bak sql1:\var\opt\mssql\backup
  3. Inside Docker
    Restore database – use script – may need to Move files

 

Bake files into an image for reuse

docker commit sql1 sqltestco:sql2017
docker images

Clean up with:
docker rmi sqltestco:sql2017

 

Use image to create docker images

Now we have an image with our database in it. We may want to use it once or many times.

Keep changing the name and the port
I found that –name needs to come first

docker run –name sqltestco1 -d -p 1434:1433 sqltestco:sql2017
docker run –name sqltestco2 -d -p 1435:1433 sqltestco:sql2017

Now have 3 instances of SQL running.

As needed:

docker start
docker stop
docker rm

 

Push images to Docker Hub

Use:
docker images
docker tag <imageid>:<tagname> <dockerId>/<repository>:<tagname>
docker login (good idea to spell everything correctly)
docker push <dockerId>/<repository>:<tagname>

Took a few attempts – got there. Private repository.

 

 

Troubleshooting

Seem to get a conflict if other containers exist but are stopped. Possibly good practice to be aware of all containers with:

docker ps -a

Error response from daemon: … userland proxy

Error response from daemon: driver failed programming external connectivity on endpoint … Error starting userland proxy: mkdir /port…

Restart docker – fixed it for me.

 

See also

Pluralsight : Getting started with Docker on Windows

https://app.pluralsight.com/library/courses/docker-windows-getting-started/table-of-contents

 

 

 

Create an ODBC using a reg edit file

With thanks to:

https://kencenerelli.wordpress.com/2012/07/26/export-an-odbc-data-source-from-the-registry/

Save following as a file e.g. MyODBCName.reg
Double-click to install into the registry


Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\ODBC Data Sources]
"MyODBCName"="SQL Server Native Client 11.0"

[HKEY_CURRENT_USER\SOFTWARE\ODBC\ODBC.INI\MyODBCName]
"Driver"="C:\\Windows\\SysWOW64\\sqlncli11.dll"
"Server"="MyServerName"
"Database"="MyDatabaseName"
"LastUser"="MyLastUserName"

How to keep the task bar visible when using a maximised RDP client

I use RDP a lot now, but would like to be able to see my own PC’s task bar, for instance Outlook may show messages.
It is possible, with thanks to:
http://notworthrepeating.blogspot.co.uk/2012/03/maximizing-remote-desktop-client.html

So:

  1. Edit your .RDP file using Remote Desktop Client, making sure the “Display” tab is configured for “Full Screen”, and then “Save” the .RDP file again (this bakes your local resolution into the file, which is important)
  2. Edit the .rdp in notepad:
    1. screen mode id:i:2  – change this line to the following, to use windowed mode instead of fullscreen
      screen mode id:i:1
    2. Add this line to the file if it doesn’t exist already:
      smart sizing:i:1
    3. Change nothing about (but take notice of) two lines that talk about “desktopwidth” and “desktopheight”
  3. Save and close the .RDP file

Thanks.

 

Device and Resource Redirection

https://technet.microsoft.com/en-us/library/cc725887(v=WS.10).aspx

Audio redirection

  1. Run
  2. Type “group” to open Edit group policy
  3. Local computer policy
  4. Computer configuration
  5. Administrative Templates
  6. Windows Components
  7. Remote Desktop Services
  8. Remote Desktop Session Host
  9. Device and Resource Redirection
  10. Allow Audio and video playback redirection
  11. Change from Not Configured to Enabled.

 

 

 

How to reinstate Contact Linking in Outlook 2013

For Outlook 2007 and 2010 there is an Option > Contacts > Linking > Show contacts linked to the current item

This has been removed in Outlook 2013, apparently because they have a new feature of Links when you are on People and the current view is People and then look at details. I don’t use that but and tend to use the List view which does not have the links. Also I have historic links, so wanted to reinstate links. Thanks to:

http://www.slipstick.com/outlook/2013/show-contact-linking-fields-in-outlook-2013/

Which I found via

Tip 375: Outlook 2007 (and 2010): Contact Linking

So steps copied from first of these are:

  1. Regedit
  2. HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Outlook\Preferences
  3. Add DWORD: ShowContactFieldObsolete
  4. Set to 1

That page also referred to a Group Policy registry setting. I did not have that on my machine, did not create it and found that the links were there anyway

To remove:

Set to 0, or remove the Key

Solved.

 

MS Word 2013 ActiveDocument.MailMerge.OpenDataSource not available for reading on opening a document

A new PC has MS Office 2013 when the system still uses Office 2003 templates and vba code.

Error:

Don’t have actual text to hand, but something like:

“MailMerge.OpenDataSource is not available for reading”

 

Solution:

Programmatically change the view on open:

Private Sub Document_Open()
Me.ActiveWindow.View.Type = wdNormalView
End Sub

 

Found solution on web. Following was not the page, but similar

http://blogs.msmvps.com/wordmeister/2013/02/22/word2013bug-not-available-for-reading/

http://social.msdn.microsoft.com/Forums/expression/en-US/d68fe679-6a44-4437-b64a-ab6dfce4fa78/problem-with-activedocumentmailmergeopendatasource-read-only-words-documents-office-2013?forum=worddev

 

 

 

Office upload center upload failed permission issue

 

Sometimes Office upload centre just stops working.

Sometimes with failed permission, sometimes with

“OneDrive for Business found a problem while accessing the Microsoft Office Document Cache and needs to repair it before it can continue.
As part of the repair a copy of the cache will be saved as a backup and a new cache will be created.”

See also: http://community.office365.com/en-us/f/172/t/238998.aspx on time 5/14/2014 10:58 PM

If required then:

  1. Stop syncing
    http://office.microsoft.com/en-us/support/stop-syncing-a-library-with-skydrive-pro-HA102850041.aspx
  2. Rename folder as backup in case you lose files
  3. Stop related services in Task Manager Resources, including Groove, MSOSync or similar
  4. Clear cache
    http://community.office365.com/en-us/f/148/t/161576.aspxBrowse to “C:\Users\username\AppData\Local\Microsoft\Office\Spw” and delete all the content. You will see that this is all related to groove, and spw equals SharePoint Workspace.Go to “C:\Users\username\AppData\Local\Microsoft\Office\15.0\OfficeFileCache” and also delete all content from this folder. This is where all the caching from your files are stored.
    Note : Just try to delete all, if one or two items cannot be deleted, that’s OK.
  5. Sync again
    It may or may not allow you to choose a location

 

http://community.office365.com/en-us/f/148/t/215635.aspx