패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.2.0

azure_app_config

Microsoft Azure 앱 구성과 통신하기 위한 Dart 패키지입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
4.9천
좋아요
19
Pub 점수
160

패키지 설치

flutter pub add azure_app_config

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Microsoft Azure 앱 구성과의 원활한 통합을 가능하게 하는 Dart 패키지로, 애플리케이션이 Azure에서 동적으로 구성 설정을 검색하고 관리할 수 있도록 합니다. 여러 환경에 걸쳐 키-값 쌍에 대한 보안 및 실시간 액세스를 지원하며, 클라우드 네이티브 환경에서 애플리케이션 구성 관리를 위한 이상적인 솔루션입니다. 이 패키지는 Android, iOS, Web, macOS, Windows, Linux 등 모든 주요 플랫폼과 호환되어 중앙 집중식 구성 관리가 필요한 크로스플랫폼 앱에 적합합니다.

사용 사례

  • 동적 구성 관리
  • 환경별 설정
  • 클라우드 네이티브 애플리케이션 배포
  • 실시간 구성 업데이트
  • 중앙 집중형 앱 설정 저장소

주요 기능

  • Azure 앱 구성에 대한 보안 연결
  • 다중 플랫폼 지원
  • 실시간 구성 동기화
  • 환경 인식형 구성 조회
  • Flutter 앱과의 간편한 통합

적합한 대상

  • Azure를 사용하는 Flutter 앱
  • 구성 관리가 필요한 백엔드 서비스
  • 크로스플랫폼 애플리케이션
  • 인프라스트럭처용 Azure를 사용하는 팀
  • 동적 구성 업데이트가 필요한 개발자

고려 사항

  • Azure 앱 구성 인스턴스 필요
  • 인증 설정이 필요합니다 (예: SAS 토큰 또는 관리되는 ID)
  • Azure 호스팅 구성에 한정
  • 네트워크 연결 필요
  • 오프라인 사용을 위해 캐싱이 필요할 수 있습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

style: very good analysis

Azure App Configuration

This package makes it easier to communicate with Microsoft Azure App Configuration KeyValue and FeatureFlag resources.

Installation

To use this plugin, add azure_app_config to your pubspec.yaml file.

Authentication

There are two methods of authenticating Azure App Configuration:

  1. (simple) Use the connection string which can be obtained from the App Configuration Dashboard under 'Access keys'. If the connection string is invalid or not specified, an ArgumentError will occur.

  2. (complex) Use the factory constructor AzureAppConfig.customAuthentication() which enables you to provide a custom way of signing requests.

Example

Example 1: Creating an instance of AzureAppConfig

import 'package:azure_app_config/azure_app_config.dart';

void main() {
  // Creating an instance needs a connection String. This can be
  // obtained through the Azure Portal, under "Access Keys".
  final service = AzureAppConfig(connectionString: '<CONNECTION_STRING>');

  // Use the service instance to interact with Azure App Configuration.
  // ...
}

Example 2: Retrieving a key value from Azure App Configuration

import 'package:azure_app_config/azure_app_config.dart';

void main() async {
  const exampleKey = 'example_key';
  const exampleLabel = 'example_label';

  final service = AzureAppConfig(connectionString: '<CONNECTION_STRING>');

  // Getting a key value.
  try {
    final keyValue = await service.getKeyValue(key: exampleKey, label: exampleLabel);
    // Use the keyValue instance to retrieve any property of the key value.
    // ...
  } catch (err) {
    // Handle any exceptions that might occur when interacting with the Azure
    // service.
  }
}

Example 3: Retrieving a feature flag from Azure App Configuration

import 'dart:developer' as developer;

import 'package:azure_app_config/azure_app_config.dart';

void main() async {
  const exampleKey = 'example_key';
  const exampleLabel = 'example_label';

  final service = AzureAppConfig(connectionString: '<CONNECTION_STRING>');
  
  final keyValue = await service.getKeyValue(key: exampleKey, label: exampleLabel);

  // If the KeyValue is a FeatureFlag, you can use .asFeatureFlag()
  // to get the properties of the FeatureFlag
  final featureFlag = keyValue.asFeatureFlag();

  // .asFeatureFlag() will return null if it's unable to parse.
  if (featureFlag != null) {
    // To check if the featureflag is enabled, use
    developer.log('${featureFlag.enabled}');
  }
} 

Example 4: Retrieving a feature flag with feature filters from Azure App Configuration

import 'dart:developer' as developer;

import 'package:azure_app_config/azure_app_config.dart';

void main() async {
  const exampleKey = 'example_key';
  const exampleLabel = 'example_label';

  final service = AzureAppConfig(connectionString: '<CONNECTION_STRING>');

  // Register a FeatureFilter before using it.
  service.registerFeatureFilter(
    FeatureFilter.targeting(
      user: 'test.user@company.com',
    ),
  );
  
  try {
    // getFeatureEnabled() will take the feature filters into account when evaluating. 
    final isFeatureEnabled = await service.getFeatureEnabled(key: exampleKey, label: exampleLabel);

    developer.log('$isFeatureEnabled');
  } catch (err) {
    // Handle any exceptions that might occur when interacting with the Azure
    // service.
  }
}

Example 5: Finding key values based on a key and label filter

import 'dart:developer' as developer;

import 'package:azure_app_config/azure_app_config.dart';

void main() async {
  final service = AzureAppConfig(connectionString: '<CONNECTION_STRING>');

  try {
    // Find key values based on a key and label filter.
    // This example searches for the keyValues that start with '.appconfig.'
    // without a label.
    final keyValues = await service.findKeyValuesBy(
      key: '.appconfig.*',
      label: AzureFilters.noLabel,
    );

    // Loop through the values.
    for (final keyValue in keyValues) {
      developer.log(keyValue.value);
      // Use the keyValue instance to retrieve any property of the key value.
      // ...
    }
  } on AzureFilterValidationException catch (e) {
    // When an invalid filter has been provided, for example, '.appconfig.**',
    // an [AzureFilterValidationException] is thrown.
    developer.log(e.errorResponse.detail ?? 'Error occurred!');
  } catch (err) {
    // Handle any exceptions that might occur when interacting with the Azure
    // service.
  }
}

Complex Types

You are able to register types with their associated encode and decode functions. After registering the types, the library will automatically use those functions to retrieve/set values in the database.

class TimeRange {
    String start;
    String end;
    TimeRange(this.start, this.end);
    factory TimeRange.fromJson(Map<String, dynamic>)
    Map<String, dynamic> toMap() => {'start': start, 'end': end}
}

...

// Register a type, so that the library knows how to encode and decode the model
service.registerType<TimeRange>(
  decode: (jsonData) => TimeRange.fromJson(jsonData),
  encode: (timeRange) => timeRange.toMap(),
);

// Uses the passed-in [encode] method to know the json structure to use.
await service.setTyped(
    TimeRange('Monday', 'Friday'),
    key: 'time_range',
    label: 'some_label',
);

// Uses the passed-in [decode] method to know how to serialize [TimeRange]
final timeRange = await service.getTyped<TimeRange>(
    key: 'time_range',
    label: 'some_label',
); 

FeatureFilters

This package currently has 2 built-in FeatureFilters based on the defaults which can be found in the App Configuration dashboard:

Microsoft.Targeting -> Enable a flag based on some Targeting parameters which can be found in the Azure dashboard.

Microsoft.TimeWindow -> Enable a feature flag during a specified window of time.

Make sure to register the FeatureFilter before retrieving a feature's value.
service.registerFeatureFilter(FeatureFilter.timeWindow()) or
service.registerFeatureFilter(FeatureFilter.targeting()).

Implement your own FeatureFilter

This package enables you to create custom FeatureFilters by extending the FeatureFilter class. An example of this can be found by looking at how the built-in FeatureFilters are implemented here.

More Information

For more information about Azure App Configuration, take a look at the following resources.

Feel free to submit any pull requests!

카테고리

의존성

의존성 목록 6 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.