Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-CosmosDbDatabase -ErrorAction SilentlyContinue results in script hangs #132

Closed
4 tasks
dannythunder opened this issue Jun 29, 2018 · 3 comments
Closed
4 tasks
Assignees
Labels
bug The issue is a bug. in progress The issue is being actively worked on by someone.

Comments

@dannythunder
Copy link

Before submitting your issue for the CosmosDB project, please take a moment to provide the following details:

  • Version of PowerShell you're using

$PSVersionTable.PSVersion

Major - Minor - Build - Revision


5 - 1 - 16299 - 492

  • PowerShell host you're using (eg. Console Host, ISE, Visual Studio)

ISE

  • Operating system you're running

Windows 10 Enterprise:
[System.Environment]::OSVersion.Version

Major - Minor - Build - Revision


10 - 0 - 16299 - 0

  • Version of CosmosDB you're using (use Get-Module -Name CosmosDB)

2.1.1.498


I'm creating a script to automate the process of creating a new environment and seed all data.
If something goes wrong, I want to be able to re-run the script. Therefore I need to check if my database is already created:

Get-CosmosDbDatabase -Context $cosmosDbContext -Id 'Maskin' -ErrorVariable ev -ErrorAction SilentlyContinue

If the database doesnt exist, I get a 404. I dont want this to break my script. Therefore I want to silently continue and move on:

if($ev -ne $null) -> create the database.

If i use -ErrorAction SilentlyContinue, the scripts seems to hang.

Workaround is to use try/catch.

@PlagueHO PlagueHO self-assigned this Jun 30, 2018
@PlagueHO PlagueHO added bug The issue is a bug. in progress The issue is being actively worked on by someone. labels Jun 30, 2018
@PlagueHO
Copy link
Owner

Thanks for raising this @dannythunder - I'll get this sorted. Might be to do with how the exceptions are being handled. I'll check this is flowing through.

@PlagueHO
Copy link
Owner

PlagueHO commented Jul 3, 2018

Sorry about the delay. I have replicated and fixed the error. I'll release the new version tonight.

@PlagueHO
Copy link
Owner

PlagueHO commented Jul 3, 2018

This fix has gone out to the PSGallery in 2.1.2: https://www.powershellgallery.com/packages/CosmosDB/2.1.2.514

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug. in progress The issue is being actively worked on by someone.
Projects
None yet
Development

No branches or pull requests

2 participants