Repository: microsoft/onefuzz
File: src/ApiService/ApiService/Functions/Scaleset.cs (C#)

Code before:
        }

        var create = request.OkV;
        // verify the pool exists
        var poolResult = await _context.PoolOperations.GetByName(create.PoolName);
        if (!poolResult.IsOk) {
            return await _context.RequestHandling.NotOk(req, answer.ErrorV, "ScalesetCreate");
        }

        var pool = poolResult.OkV;
        if (!pool.Managed) {
            return await _context.RequestHandling.NotOk(
                req,
                new Error(
                    Code: ErrorCode.UNABLE_TO_CREATE,
                    Errors: new string[] { "scalesets can only be added to managed pools " }),
                context: "ScalesetCreate");
        }

        string image;
        if (create.Image is null) {
            if (pool.Os == Os.Windows) {
                image = (await _context.ConfigOperations.Fetch()).DefaultWindowsVmImage;
            } else {
                image = (await _context.ConfigOperations.Fetch()).DefaultLinxuVmImage;
            }
        } else {
            image = create.Image;
        }

        Region region;
        if (create.Region is null) {
            region = await _context.Creds.GetBaseRegion();
        } else {
            var validRegions = await _context.Creds.GetRegions();
            if (!validRegions.Contains(create.Region)) {
                return await _context.RequestHandling.NotOk(
                    req,
                    new Error(
                        Code: ErrorCode.UNABLE_TO_CREATE,
                        Errors: new string[] { "invalid region" }),
                    context: "ScalesetCreate");
            }

            region = create.Region;
        }

        var availableSkus = await _context.VmssOperations.ListAvailableSkus(region);
        if (!availableSkus.Contains(create.VmSku)) {
            return await _context.RequestHandling.NotOk(
                req,

Review comment (suggestion):
Small tidy up:

```suggestion
            var config = await _context.ConfigOperations.Fetch();
            if (pool.Os == Os.Windows) {
                image = config.DefaultWindowsVmImage;
            } else {
                image = config.DefaultLinxuVmImage;
            }
```

Code after:
        }

        var create = request.OkV;
        // verify the pool exists
        var poolResult = await _context.PoolOperations.GetByName(create.PoolName);
        if (!poolResult.IsOk) {
            return await _context.RequestHandling.NotOk(req, answer.ErrorV, "ScalesetCreate");
        }

        var pool = poolResult.OkV;
        if (!pool.Managed) {
            return await _context.RequestHandling.NotOk(
                req,
                new Error(
                    Code: ErrorCode.UNABLE_TO_CREATE,
                    Errors: new string[] { "scalesets can only be added to managed pools " }),
                context: "ScalesetCreate");
        }

        string image;
        if (create.Image is null) {
            var config = await _context.ConfigOperations.Fetch();
            if (pool.Os == Os.Windows) {
                image = config.DefaultWindowsVmImage;
            } else {
                image = config.DefaultLinuxVmImage;
            }
        } else {
            image = create.Image;
        }

        Region region;
        if (create.Region is null) {
            region = await _context.Creds.GetBaseRegion();
        } else {
            var validRegions = await _context.Creds.GetRegions();
            if (!validRegions.Contains(create.Region)) {
                return await _context.RequestHandling.NotOk(
                    req,
                    new Error(
                        Code: ErrorCode.UNABLE_TO_CREATE,
                        Errors: new string[] { "invalid region" }),
                    context: "ScalesetCreate");
            }

            region = create.Region;
        }

        var availableSkus = await _context.VmssOperations.ListAvailableSkus(region);
        if (!availableSkus.Contains(create.VmSku)) {
            return await _context.RequestHandling.NotOk(