Tag: DevOps

  • Set a Runtime Variable in an Azure DevOps Pipeline

    Note: I DO NOT recommend this. Any changes to a pipeline should be in code and through a PR.

    That being said, I know this information is out there and some people need it. The question from a friend was how can they set a variable in an Azure DevOps Pipeline at runtime. This was for testing, and they wanted to change the pipeline behavior to test things when they ran them.

    This post will show how to do this in classic and YAML pipelines. As a scenario, I’m just going to get a directory listing of a folder, and change that at runtime.

    Classic Pipelines

    I know the trend is everything in code. For experimenting and learning, I find this slightly annoying, so I like classic pipelines. I know others do.

    In a classic pipeline, I can set variables. I’ll add a new one and call it myLocation. Over on the far right, there is a checkbox for “settable at runtime”. Check that.

    2024-06-27 14_42_03-Dir Project-CI - Azure DevOps Services

    Now, I’ll add a task to this pipeline that runs a dir, using this variable.

    2024-06-27 14_54_13-Dir Project-CI - Azure DevOps Services

    I can save and run this, and I see the results of c:\Users from a hosted agent.

    2024-06-27 14_50_22-Pipelines - Run 1346 logs

    That’s the default behavior.

    Now, let’s alter this at runtime. When I click “run pipeline, I see this on the right side as a blade. Note the “variables” section below.

    2024-06-27 14_50_50-Pipelines - Runs for Dir Project-CI

    I can click this and see my variables. System.debug is set at runtime by default, but I see my other one.

    2024-06-27 14_53_35-Media Player

    If I click this, I can change the location. I’ll set this to c:\.

    2024-06-27 14_50_40-

    When I let this run, note I get different results.

    2024-06-27 14_53_10-Pipelines - Run 1347 logs

    I’ve changed behavior at runtime.

    YAML Pipelines

    In a YAML pipeline, I don’t have tabs or variables. Instead, I just get a script of sections, like this.

    2024-06-27 14_58_28-Dir Project - Pipelines

    I can alter this to add a variable by looking in the upper right, where I see a “variables” button. Click this.

    2024-06-27 14_59_05-Dir Project - Pipelines

    I get a list of variables, which is none in this case. I’ll click “New variable”.

    2024-06-27 14_59_08-Media Player

    This gives me a dialog where I can enter the information. Note I can set a default as well as let users override this with a checkbox.

    2024-06-27 14_59_19-Dir Project - Pipelines

    When I save this, I see my variable.

    2024-06-27 14_59_24-Dir Project - Pipelines

    Now, I can alter my script. I’ll add this as $(myLocation), where I surround the variable name with a $ and ().

    2024-06-27 14_59_53-Dir Project - Pipelines

    I can validate and save this, which I do.

    2024-06-27 14_59_57-GPT-5 delayed , TikTok kill switch , inside Netflix's video encoding ‍ -

    It’s valid, because I typed well, but this really should go through a PR. Since I’m testing, and I’d approve the PR, I’m doing it in main. I shouldn’t do this in any org.

    2024-06-27 15_00_02-Dir Project - Pipelines

    Now when I run the pipeline, I have the variables item where I can change the variable.

    2024-06-27 15_00_17-Dir Project - Pipelines

    I can also set this variable in YAML, like this:

    2024-06-27 15_06_50-azure-pipelines.yml - Repos

    However, if I set that value, I can’t change this at runtime. Here’s the runtime screen.

    2024-06-27 15_07_56-Window

    I can use a parameter instead. I’ll use this structure:

    2024-06-27 15_23_21-Dir Project - Pipelines

    When I run this, I see a new box:

    2024-06-27 15_18_50-Dir Project - Pipelines

    I can override this “Dir location”. When I set this to c:\, I see these results:

    2024-06-27 15_25_19-Pipelines - Run 20240627.17 logs

    Summary

    I’ve shown how to configure a variable to be set at runtime, both in classic and YAML pipelines.

    Note, this a place an administrator can make a mistake, or run rogue, without review. This is not recommended. Put all pipeline changes through a PR.

  • The Cost of Rework

    I often deal with customers who are looking to improve the way they build and manage database software. These could be small companies or large enterprises, with teams of developers trying to enhance their application software to solve new business problems. Often those enhancements require new data, with the related schema changes in a database. Even if there isn’t any new data, often we need to query data in new ways, combing, filtering, aggregating, and otherwise transforming data into extra information that a business can use.

    Solving many of these problems is iterative by nature. We try one thing, then another. Often a developer might experiment with a data model or query, trying to match a requirement they’ve been given. Once they produce a solution, we may find problems in testing, or far too regularly, in production. These could be data-related issues, where the developer hasn’t considered values in their solution (zeros, blank or long strings, extreme dates, etc.). These could be logical errors, where the developer just made a mistake. There could also be a problem with the requirement, where the customer provided an incomplete or incorrect specification to the developer.

    In any of these cases, what often happens is rework. We need to re-look at the code we’ve written and change it in some way. This isn’t a complete rewrite, but looking for the logical error, incomplete algorithm, or poorly performing structures. Then we need to (test it and ) move the code back through our process of deploying to QA, UAT, production and anywhere else the problem exists. The further we are in the process (closer to production) the more costly the effort to rework code.

    Some rework is unavoidable, but I think quite a bit isn’t. If we wrote better-performing and cleaner code the first time and had a pattern for testing our code, we might avoid a fair amount of rework. If we caught silly mistakes early, we could get more done.

    I think that often developers minimize the effort required to perform rework. They think small changes are easy. After all, we already know the problem space, we’ve looked at it, and the fix should be quicker than the initial analysis and development.

    Or is it?

    One of the things I’ve seen is that everyone is busy. We are pulled in many directions by many different people and work on lots of different problems. Even when we work on the same application every week, it takes some time to remember the context under which we wrote the code. If it’s not our code, then we spend time trying to understand how the original developer approached the problem. Without good specifications or tests, we might not view things the same way during rework. We often fix one problem but create another.

    Automated testing should help here, as the tests should codify the understanding of the requirements, but too few database developers use automated testing for their code. Even developers who embrace testing from the application might not have sufficient test data to ensure their code will work in production.

    Most of us are expected to do more work this year than last year. We’re constantly battling a lack of resources. We can’t necessarily write more code, but we can learn to be more efficient. We can learn to reduce our rework by writing code better the first time. That takes some effort and knowledge. It takes working as a team, sharing successes and struggles, and adapting our code to use patterns and avoid anti-patterns. It requires some automation to embrace static code analysis and testing to avoid silly mistakes getting deployed and wasting time. More importantly, it takes support from management to spend time learning as a team to produce better code and avoid silly mistakes.

    A little investment in learning and practice goes a long way. Unfortunately, too many people, both staff and management, are unwilling to commit. Except in fixing bugs and spending time on rework. Far too many people see that as an regular, accepted part of software development.

    Steve Jones

    Listen to the podcast at Libsyn, Spotify, or iTunes.

    Note, podcasts are only available for a limited time online.

  • SQL Saturday South Florida 2024 Powerpoint Decks

    Thanks to everyone who attended my sessions today at SQL Saturday South Florida. Here are the resources from today.

    Blogging for the Tech Professional

    Deck: BloggingfortheTechProfessional.pptx

    Get started with writing today. Use Word or Open Live Writer, save 10 posts offline, then set up a blog.

    Architecting Zero Downtime Deployments

    I always enjoy this talk and I hope you did. Here are the things you might need:

  • What Metrics Do You Collect?

    One of the hot terms in software these days is observability. There are a few definitions (Splunk, RadixWeb), but essentially this is the insight into how your software runs and performs using metrics, logs, traces, etc. In DevOps, we do this with an eye toward improving performance and identifying the root cause of issues. The focus is slightly different from monitoring, where we often focus more on resources and health. We need both, but often in trying to improve software and the behavior for users, developers need observability. Infrastructure people responding to acute issues and looking to ensure we have the capacity, availability, and other x-bilities, that need monitoring.

    Today I’m wondering if you collect a variety of types of metrics for your software that might tell you how your system is running. What things are important to you in order to better serve your clients? If you’re a DBA/sysadmin, what is important to you? If you are a developer, are there different types of data you want?

    Certainly, you might collect various resource measures (CPU, IO, reads, etc.), but there are many more things. There are logs, which could include the SQL Server error log, but I’d hope that you had a more in-depth way of measuring the activity on your system. Do you have custom xEvent traces running? Can you collect application logs easily when you’re looking at issues? Do you spend time trying to solve chronic issues? Do you look for potential future problems?

    Most software applications should include some sort of basic logging of major functions, but I would hope that there are various levels available. If problems are reported or noticed, can you increase the detail of logging? Can you correlate this with logs from different systems, such as the database? Can I get execution data that matches calls and trace down the potential issues that users are experiencing?

    I know that we have problems in applications. Some (many?) of these are data-related, which might be easy or hard to trace down. That often depends if the data changes too quickly or is static enough for someone to investigate a report. Some errors are logical code errors, which might indicate a lack of testing early in the software process, but we ought to be able to determine this quickly from logs. If there are performance issues, and we have a lot of these, how easily can we verify a problem?

    Let us know what types of metrics help you solve issues. I certainly think that you should have some sort of monitoring and observability system in place that helps you dive deep into the database, especially concerning execution plans at the time of the issue. The situation can change quickly inside a database, so capturing data regularly is important. If there is something you wish you had, let us know as well. Maybe someone else will have a neat solution for you.

    Steve Jones

    Listen to the podcast at Libsyn, Spotify, or iTunes.

    Note, podcasts are only available for a limited time online.