Category: Blog

  • Cleaning up Azure Client IPs

    I travel around, and as a result, I may find myself accessing my Azure databases from different locations. Since it’s a quick click and login to add my IP from SSMS, I’ll end up with multiple ones. I don’t want to leave systems open for a long time, and certainly don’t want to just add 0.0.0.0 without good reason.

    As a result, I periodically clean things up. I’d like to do this after each trip, but I sometimes forget. Here’s how I do this in the Portal.

    First, I need to access my server, not my database. Servers are separate from databases, as you can see below. This isn’t an instance, but rather a logical construct for holding multiple databases.

    2018-05-22 08_26_04-Window

    From here, I get a list, and I can click one.

    2018-05-22 08_26_10-Window

    When I do this, I get the details of the server. On the right side of the overview are the firewall settings.

    2018-05-22 08_26_21-Window

    Click this and you see the list of firewall rules. Each of these has a name, a starting and ending IP range. You don’t really need to worry about this much if you’re a dev. If you want to give access to a group of IPs because your  company has them, talk to your network admin about the addressing.

    On the right side are three dots. Click these to get the delete option.

    2018-05-22 08_28_14-Window

    I click through these and it’s really quick. I can remove 10 IPs in about 20 seconds, so I don’t bother with too much automation here. I could use PoSh, but it might take me longer to figure out what to do than just click a few times.

    I can also edit a row. If I click the middle, I get edit boxes, and as you see, I can rename a rule that makes sense. I ought to do this for other times, but since I add access from SSMS in hotels, I don’t often go to the server at that time.

    2018-05-22 08_29_00-Window

    It can be a pain, and if I tended to work with a lot of different servers (I have 4), I’d likely automate this more.

    Actually I’ll automate it in another post as it’s a good skill to have.

  • Hands off dbatools updates

    I really like the dbatools project. This is a series of PowerShell cmdlets that are built by the community and incredibly useful for migrations between SQL Servers, but also for various administrative actions. I have a short series on these items.

    One of the downsides of an active project is that updates happen often. I know when I’m working with new versions of Redgate tools, they’ll deliver new builds to me every day if I want them (I usually don’t).

    With dbatools, I find a similar issue, though at a slightly longer scale. I’ll see a tweet or post about a new cmdlet, only to find out that I don’t have the newest version. As a result, I need to update my modules, which means I need an elevated command window, which is distracting.

    I saw a post about someone that built a SQL Agent task to update their server, which I was thinking to do until Anthony Nocentino pointed out Watch-DbaUpdate.

    Install-DbaUpdate

    There’s actually a cmdlet that does what I want. It’s Install-DbaWatchUpdate, and it’s designed to setup a scheduled task that calls Watch-DbaUpdate and updates the module. That’s what I want, so I decided to check it out.

    First, I looked at Scheduled Tasks. In Windows 10, this is the Task Scheduler from the Start menu, and surprisingly, lots of software uses this. Google, Adobe, Microsoft, etc.

    2018-05-22 16_20_00-Task Scheduler

    I then tried the –WhatIf parameter for Install-DbaWatchUpdate, but it didn’t work. I know this is a fun cmdlet, but this should work.

    2018-05-22 16_21_02-cmd - powershell (Admin)

    In any case, let me just run it. I don’t get much detail back.

    2018-05-22 16_23_34-cmd - powershell (Admin)

    If I refresh scheduled tasks, I see a dbatools version check.

    2018-05-22 16_23_50-Task Scheduler

    If you look at the details, this is triggered at midnight and runs once an hour. The PoSh executable is called and it in turn calls the Watch-DbaUpdate cmdlet, which checks for a new version and should let me know if there are updates. Since I’m at the latest version, I’ll have to see if this works.

    So far, so good.

    I even tested the Uninstall-DbaWatchUpdate and it does remove the task.

  • One Week to Music City Tech

    Next week is Music City Tech, a three day conference consisting of Coding, Agile, and Data tracks, takes place in Nashville on May 31-June 2. There are a lot of great sessions on the schedule, covering a lot of software development topics.

    I’ll be delivering two talks, one on DevOps and one on security/encryption on Saturday. I’m looking forward to the conference, with some great .NET and development talks on Thursday and Friday, with a nice spread of data talks on Saturday.

    If you’re near the area, you can get tickets for a very reasonable price for the conference. I hope to see you next week.

  • Jobs in PoSh to Create a Load

    I saw this from Argenis Fernandez, and thought it was wonderful.

    1..128 | % { start-job -name ‘job name’ -scriptblock { & sqlcmd -S instanceName -U sa -P ‘iLovePoSh’ -i /home/username/test.sql } }

    Create 128 threads, each running a background job in PowerShell to connect to an instance and run a script file.

    Start-Job is used to begin a job, and then you can get information from Get-Job and use Stop-Job to turn things off.

    Very cool. Looking forward to trying to use this in a demo and make things happen.