Category: Uncategorized

  • Use client certificates to secure access to an API

    Certificates can be used to provide TLS mutual authentication between the client and the API gateway. You can configure the API Management gateway to allow only requests with certificates containing a specific thumbprint. The authorization at the gateway level is handled through inbound policies.

    For your meteorological app, you have some customers who have client certificates issued by a certificate authority (CA) that you both trust. You want to allow those customers to authenticate by passing those certificates.

    Here, you’ll learn how to configure API Management to accept client certificates.

  • What is API Management?

    Azure API Management helps organizations unlock the potential of their data and services by publishing APIs to external partners and internal developers. Businesses are extending their operations as a digital platform by creating new channels, finding new customers, and driving deeper engagement with existing ones. API Management provides the core competencies to ensure a successful API program through developer engagement, business insights, analytics, security, and protection. You can use API Management to take any backend and launch a full-fledged API program based on it.

    To use API Management, administrators define APIs in the portal. Each API consists of one or more operations and can be added to one or more products. To use an API, developers subscribe to a product that contains that API, then call the API’s operations, subject to any usage policies that might be in effect. Common scenarios include:

    • Securing mobile infrastructure by gating access with API keys, preventing distributed denial of service (DDoS) attacks by using throttling, or using advanced security policies like JSON web token (JWT) validation.
    • Offering fast partner onboarding through the developer portal to independent software vendor (ISV) partner ecosystems, enabling them to build an API facade to decouple from internal implementations that aren’t ready for partner consumption.
    • Running an internal API program that offers a centralized location for the organization to communicate between the API gateway and the backend. Communications about the availability and latest changes to APIs would be on a secured channel with gated access based on organizational accounts.

    Components of API Management

    API Management is made up of the following components:

    API gateway

    The API gateway is the endpoint that:

    • Accepts API calls and routes them to the backend.
    • Verifies API keys, JWT tokens, certificates, and other credentials.
    • Enforces usage quotas and rate limits.
    • Transforms your API on the fly without code modifications.
    • Caches backend responses, where the capability is set up.
    • Logs call metadata for analytics purposes.

    Azure portal

    The Azure portal is the administrative interface where you set up your API program. You can also use it to:

    • Define or import API schema.
    • Package APIs into products.
    • Set up policies such as quotas or transformations on the APIs.
    • Get insights from analytics.
    • Manage users.

    Developer portal

    The developer portal serves as the main web presence for developers. From here, they can:

    • Read API documentation.
    • Try out an API via the interactive console.
    • Create an account and subscribe to get API keys.
    • Access analytics on their own usage.
  • Discover the API Management service

    API Management provides the core functionality to ensure a successful API program through developer engagement, business insights, analytics, security, and protection. Each API consists of one or more operations, and each API can be added to one or more products. To use an API, developers subscribe to a product that contains that API, and then they can call the API’s operation, subject to any usage policies.

  • Forward request

    The forward-request policy forwards the incoming request to the backend service specified in the request context. The backend service URL is specified in the API settings and can be changed using the set backend service policy.

    Removing this policy results in the request not being forwarded to the backend service. The policies in the outbound section are evaluated immediately upon the successful completion of the policies in the inbound section.

    XMLCopy

    <forward-request timeout="time in seconds" follow-redirects="true | false"/>
    

    Limit concurrency

    The limit-concurrency policy prevents enclosed policies from executing by more than the specified number of requests at any time. When requests exceed that number, new requests fail immediately with a 429 Too Many Requests status code.

    XMLCopy

    <limit-concurrency key="expression" max-count="number">
            <!— nested policy statements -->
    </limit-concurrency>
    

    Log to Event Hubs

    The log-to-eventhub policy sends messages in the specified format to an event hub defined by a Logger entity. As its name implies, the policy is used for saving selected request or response context information for online or offline analysis.

    XMLCopy

    <log-to-eventhub logger-id="id of the logger entity" partition-id="index of the partition where messages are sent" partition-key="value used for partition assignment">
      Expression returning a string to be logged
    </log-to-eventhub>
    

    Mock response

    The mock-response, as the name implies, is used to mock APIs and operations. It aborts normal pipeline execution and returns a mocked response to the caller. The policy always tries to return responses of highest fidelity. It prefers response content examples, whenever available. It generates sample responses from schemas, when schemas are provided and examples aren’t. If examples or schemas aren’t found, responses with no content are returned.

    XMLCopy

    <mock-response status-code="code" content-type="media type"/>
    

    Retry

    The retry policy executes its child policies once and then retries their execution until the retry condition becomes false or retry count is exhausted.

    XMLCopy

    <retry
        condition="boolean expression or literal"
        count="number of retry attempts"
        interval="retry interval in seconds"
        max-interval="maximum retry interval in seconds"
        delta="retry interval delta in seconds"
        first-fast-retry="boolean expression or literal">
            <!-- One or more child policies. No restrictions -->
    </retry>
  • Create advanced policies

    This unit provides a reference for the following API Management policies:

    • Control flow – Conditionally applies policy statements based on the results of the evaluation of Boolean expressions.
    • Forward request – Forwards the request to the backend service.
    • Limit concurrency – Prevents enclosed policies from executing by more than the specified number of requests at a time.
    • Log to Event Hubs – Sends messages in the specified format to an event hub defined by a Logger entity.
    • Mock response – Aborts pipeline execution and returns a mocked response directly to the caller.
    • Retry – Retries execution of the enclosed policy statements, if and until the condition is met. Execution repeats at the specified time intervals and up to the specified retry count.

    Control flow

    The choose policy applies enclosed policy statements based on the outcome of evaluation of boolean expressions, similar to an if-then-else or a switch construct in a programming language.

    XMLCopy

    <choose>
        <when condition="Boolean expression | Boolean constant">
            <!— one or more policy statements to be applied if the above condition is true  -->
        </when>
        <when condition="Boolean expression | Boolean constant">
            <!— one or more policy statements to be applied if the above condition is true  -->
        </when>
        <otherwise>
            <!— one or more policy statements to be applied if none of the above conditions are true  -->
    </otherwise>
    </choose>
    

    The control flow policy must contain at least one <when/> element. The <otherwise/> element is optional. Conditions in <when/> elements are evaluated in order of their appearance within the policy. Policy statements enclosed within the first <when/> element are applied when the condition attribute is true. Policies enclosed within the <otherwise/> element, if present, are applied if all of the <when/> element condition attributes are false.

  • Discover the API Management service

    API Management provides the core functionality to ensure a successful API program through developer engagement, business insights, analytics, security, and protection. Each API consists of one or more operations, and each API can be added to one or more products. To use an API, developers subscribe to a product that contains that API, and then they can call the API’s operation, subject to any usage policies.

  • Complete the challenge to convert Fahrenheit to Celsius

    In this challenge, you’ll write code that will use a formula to convert a temperature from degrees Fahrenheit to Celsius. You’ll print the result in a formatted message to the user.

    Challenge: Calculate Celsius given the current temperature in Fahrenheit

    1. Select all of the code in the .NET Editor, and press Delete or Backspace to delete it.
    2. Enter the following code in the .NET Editor:C#Copyint fahrenheit = 94;
    3. To convert temperatures in degrees Fahrenheit to Celsius, first subtract 32, then multiply by five ninths (5 / 9).
    4. Display the result of the temperature conversion in a formatted messageCombine the variables with literal strings passed into a series of Console.WriteLine() commands to form the complete message.
    5. When you’re finished, the message should resemble the following output:OutputCopyThe temperature is 34.444444444444444444444444447 Celsius.
  • Integrate Dataflows Gen2 and Pipelines in Microsoft Fabric

    Dataflows Gen2 provide an excellent option for data transformations in Microsoft Fabric. The combination of dataflows and pipelines is useful when you need to perform additional operations on the transformed data.

    Data pipelines are a common concept in data engineering and offer a wide variety of activities to orchestrate. Some common activities include:

    • Copy data
    • Incorporate Dataflow
    • Add Notebook
    • Get metadata
    • Execute a script or stored procedure

    Pipelines provide a visual way to complete activities in a specific order. You can use a dataflow for data ingestion, transformation, and landing into a Fabric data store. Then incorporate the dataflow into a pipeline to orchestrate extra activities, like execute scripts or stored procedures after the dataflow has completed.

  • GitHub Copilot on GitHub.com

    GitHub Copilot extends beyond your local development environment to provide AI assistance directly on GitHub.com. When working with repositories, issues, pull requests, and discussions on the GitHub web interface, you can leverage Copilot’s capabilities to streamline your workflow and enhance collaboration.

    In this unit, we’ll cover:

    • How to access GitHub Copilot on GitHub.com
    • GitHub Copilot agent tasks on GitHub.com
    • Repository exploration and documentation
    • Pull request assistance
    • Issue management
    • Code review and collaboration
    • GitHub Copilot error explanation in GitHub Actions

    Accessing Copilot on GitHub.com

    Copilot is integrated throughout the GitHub web interface, appearing as a chat button or inline suggestions in various contexts. You can access Copilot features in several areas:

    • Repository pages – Get explanations of code, documentation, and project structure
    • Issues and pull requests – Generate summaries, suggest solutions, and draft responses
    • Discussions – Help formulate responses and provide technical insights
    • Code review – Analyze changes and suggest improvements

    GitHub Copilot agent tasks on GitHub.com

    When using Copilot on GitHub.com, you can perform various agent-driven tasks:

    Screenshot showing various GitHub Copilot agent tasks available on GitHub.com including repository exploration, pull request assistance, and issue management.

    These tasks can run in the background for you while you focus on other work.

    Repository exploration and documentation

    • Code explanation: Ask Copilot to explain complex code sections, functions, or entire files
    • Project overview: Get AI-generated summaries of repository purpose, architecture, and key components
    • Documentation generation: Create or improve README files, API documentation, and code comments

    Example: “Explain the main functionality of this repository and its key components”

    Screenshot of GitHub Copilot providing code explanation and repository overview on a GitHub repository page.

    Pull request assistance

    GitHub Copilot on GitHub.com significantly accelerates your pull request workflow by automating many time-consuming review and documentation tasks:

    • PR summaries: Generate comprehensive summaries of changes made in a pull request, helping reviewers quickly understand the scope and impact of modifications
    • Review suggestions: Get recommendations for code improvements and potential issues before formal review, reducing review cycles
    • Merge conflict resolution: Receive guidance on resolving conflicts between branches, streamlining the merge process
    • Documentation updates: Automatically suggest updates to README files, changelogs, and other documentation based on code changes
  • GitHub Copilot Chat

    GitHub Copilot Chat is an advanced feature of the GitHub Copilot ecosystem, designed to provide developers with an interactive, conversational AI assistant directly within their development environment. It allows developers to have natural language conversations about their code, ask questions, and receive intelligent responses and suggestions in real-time. In this unit, we cover:

    • How to generate code using GitHub Copilot Chat.
    • Debugging using GitHub Copilot Chat.
    • How to get code explanations using GitHub Copilot Chat.
    • Using slash commands to perform actions with GitHub Copilot.
    • Using custom GitHub Copilot agents to improve prompts.

    To access Copilot in your Integrated Development Environment(IDE), click the chat icon on the left navbar.

    Screenshot of Chat.

    GitHub Copilot Chat is beneficial in certain scenarios:

    • Complex code generation When you need to implement complex algorithms, data structures, or generate boilerplate code for specific design patterns, Copilot Chat can help streamline the process. It can help create intricate regular expressions, construct detailed SQL queries, or develop advanced data structures like a Bubble sort in Python.