Skip to main content
Glama

Azure MCP Server

Official
MIT License
1,161
  • Linux
  • Apple
LogsGetCommand.cs2.98 kB
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using AzureMcp.Core.Commands; using AzureMcp.Core.Commands.Subscription; using AzureMcp.Core.Services.Telemetry; using AzureMcp.Deploy.Options; using AzureMcp.Deploy.Options.App; using AzureMcp.Deploy.Services; using Microsoft.Extensions.Logging; namespace AzureMcp.Deploy.Commands.App; public sealed class LogsGetCommand(ILogger<LogsGetCommand> logger) : SubscriptionCommand<LogsGetOptions>() { private const string CommandTitle = "Get AZD deployed App Logs"; private readonly ILogger<LogsGetCommand> _logger = logger; private readonly Option<string> _workspaceFolderOption = DeployOptionDefinitions.AzdAppLogOptions.WorkspaceFolder; private readonly Option<string> _azdEnvNameOption = DeployOptionDefinitions.AzdAppLogOptions.AzdEnvName; private readonly Option<int> _limitOption = DeployOptionDefinitions.AzdAppLogOptions.Limit; public override string Name => "get"; public override string Title => CommandTitle; public override ToolMetadata Metadata => new() { Destructive = false, ReadOnly = true }; public override string Description => """ This tool fetches logs from the Log Analytics workspace for Container Apps, App Services, and Function Apps deployed using azd. Use it after a successful azd up to check app status or troubleshoot errors in deployed applications. """; protected override void RegisterOptions(Command command) { base.RegisterOptions(command); command.AddOption(_workspaceFolderOption); command.AddOption(_azdEnvNameOption); command.AddOption(_limitOption); } protected override LogsGetOptions BindOptions(ParseResult parseResult) { var options = base.BindOptions(parseResult); options.WorkspaceFolder = parseResult.GetValueForOption(_workspaceFolderOption)!; options.AzdEnvName = parseResult.GetValueForOption(_azdEnvNameOption)!; options.Limit = parseResult.GetValueForOption(_limitOption); return options; } public override async Task<CommandResponse> ExecuteAsync(CommandContext context, ParseResult parseResult) { var options = BindOptions(parseResult); try { if (!Validate(parseResult.CommandResult, context.Response).IsValid) { return context.Response; } var deployService = context.GetService<IDeployService>(); string result = await deployService.GetAzdResourceLogsAsync( options.WorkspaceFolder!, options.AzdEnvName!, options.Subscription!, options.Limit); context.Response.Message = result; } catch (Exception ex) { _logger.LogError(ex, "An exception occurred getting azd app logs."); HandleException(context, ex); } return context.Response; } }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Azure/azure-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server