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

Code before:
            return await _context.RequestHandling.NotOk(
                req,
                new Error(
                    ErrorCode.INVALID_REQUEST,
                    new string[] { $"unable to find a registration associated with machine_id '{machineId}'" }),
                "agent registration");
        }

        var pool = await _context.PoolOperations.GetByName(agentNode.PoolName);
        if (!pool.IsOk) {
            return await _context.RequestHandling.NotOk(
                req,
                new Error(
                    ErrorCode.INVALID_REQUEST,
                    new string[] { "unable to find a pool associated with the provided machine_id" }),
                "agent registration");
        }

        return await RequestHandling.Ok(req, await CreateRegistrationResponse(pool.OkV));
    }

    private async Async.Task<AgentRegistrationResponse> CreateRegistrationResponse(Service.Pool pool) {


        var eventsUrl = new Uri(_context.ServiceConfiguration.OneFuzzBaseAddress, "/api/agents/events");
        var commandsUrl = new Uri(_context.ServiceConfiguration.OneFuzzBaseAddress, "/api/agents/commands");

        var workQueue = await _context.Queue.GetQueueSas(
            _context.PoolOperations.GetPoolQueue(pool.PoolId),
            StorageType.Corpus,
            QueueSasPermissions.Read | QueueSasPermissions.Update | QueueSasPermissions.Process,
            TimeSpan.FromHours(24));

        return new AgentRegistrationResponse(
            EventsUrl: eventsUrl,
            CommandsUrl: commandsUrl,
            WorkQueue: workQueue);
    }

    private async Async.Task<HttpResponseData> Post(HttpRequestData req) {
        var request = await RequestHandling.ParseUri<AgentRegistrationPost>(req);
        if (!request.IsOk) {
            return await _context.RequestHandling.NotOk(req, request.ErrorV, "agent registration");
        }

        var machineId = request.OkV.MachineId;
        var poolName = request.OkV.PoolName;
        var scalesetId = request.OkV.ScalesetId;
        var version = request.OkV.Version;
        var os = request.OkV.Os;
        var machineName = request.OkV.MachineName;

Review comment (suggestion):
```suggestion 
```suggestion 
    var baseAddress = _context.Creds.GetInstanceUrl();
    var eventsUrl = new Uri(baseAddress, "/api/agents/events");
    var commandsUrl = new Uri(baseAddress, "/api/agents/commands");
```
```

Code after:
            return await _context.RequestHandling.NotOk(
                req,
                new Error(
                    ErrorCode.INVALID_REQUEST,
                    new string[] { $"unable to find a registration associated with machine_id '{machineId}'" }),
                "agent registration");
        }

        var pool = await _context.PoolOperations.GetByName(agentNode.PoolName);
        if (!pool.IsOk) {
            return await _context.RequestHandling.NotOk(
                req,
                new Error(
                    ErrorCode.INVALID_REQUEST,
                    new string[] { "unable to find a pool associated with the provided machine_id" }),
                "agent registration");
        }

        return await RequestHandling.Ok(req, await CreateRegistrationResponse(pool.OkV));
    }

    private async Async.Task<AgentRegistrationResponse> CreateRegistrationResponse(Service.Pool pool) {
        var baseAddress = _context.Creds.GetInstanceUrl();
        var eventsUrl = new Uri(baseAddress, "/api/agents/events");
        var commandsUrl = new Uri(baseAddress, "/api/agents/commands");
        var workQueue = await _context.Queue.GetQueueSas(
            _context.PoolOperations.GetPoolQueue(pool.PoolId),
            StorageType.Corpus,
            QueueSasPermissions.Read | QueueSasPermissions.Update | QueueSasPermissions.Process,
            TimeSpan.FromHours(24));

        return new AgentRegistrationResponse(
            EventsUrl: eventsUrl,
            CommandsUrl: commandsUrl,
            WorkQueue: workQueue);
    }

    private async Async.Task<HttpResponseData> Post(HttpRequestData req) {
        var request = await RequestHandling.ParseUri<AgentRegistrationPost>(req);
        if (!request.IsOk) {
            return await _context.RequestHandling.NotOk(req, request.ErrorV, "agent registration");
        }

        var machineId = request.OkV.MachineId;
        var poolName = request.OkV.PoolName;
        var scalesetId = request.OkV.ScalesetId;
        var version = request.OkV.Version;
        var os = request.OkV.Os;
        var machineName = request.OkV.MachineName;

        if (machineId == Guid.Empty) {