napche/azure-vm-client 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

napche/azure-vm-client

Composer 安装命令:

composer require napche/azure-vm-client

包简介

Azure Virtual Machines REST API PHP library

README 文档

README

Based on https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines

Create an Azure Active Directory (AAD) Application

AAD encourages the use of Applications / Service Principals for authenticating applications. An application / service principal combination provides a service identity to manage your Azure Subscription. Click here to learn about AAD applications and service principals.

  • Install the Azure CLI
  • run az login to log into Azure
  • run az ad sp create-for-rbac to create an Azure Active Directory Application with access to Azure Resource Manager for the current Azure Subscription
    • If you want to run this for a different Azure Subscription, run az account set --subscription 'your subscription name'
  • run az account list --query "[?isDefault].id" -o tsv to get your Azure Subscription Id.

The output of az ad sp create-for-rbac should look like the following:

{
  "appId": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
  "displayName": "some-display-name",
  "name": "http://azure-cli-2017-04-03-15-30-52",
  "password": "XXXXXXXXXXXXXXXXXXXX",
  "tenant": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
}

The values tenant, appId and password are used in the Client constructor.

Example Usage

        use Azure\Entity\VirtualMachine;
        use Azure\AzureVMClient;
        use Azure\Profile\StorageProfile;
        
        $resourceGroupName = 'new-resource-group';
        $client->createResourceGroup($resourceGroupName, $region, $tag);
        
        // Create new machine
        $name = 'new_vm';
        $region = 'westeurope';
        $machine = new VirtualMachine( $name, $region );
        $machine->setResourceGroup( $resourceGroupName );
        
        // Add or change Profiles..
        $storage = new StorageProfile();
        $machine->setStorageProfile( $storage );
        
        // Create client with instant authentication.
        $client = new AzureVMClient(
            $subscriptionId,
            $tenant,
            $applicationId,
            $password
        );
        
        /*
        // Create client and authenticate LATER.
        $client = new AzureVMClient(
            $subscriptionId
        );
        
        // Do some other stuff.
        
        $client->authenticate($tenant, $applicationId, $password);
        */
        
        // Create a VM.
        $client->createVM( $machine );
        
        // Delete afterwards.
        $client->deleteResourceGroup( $resourceGroupName );

统计信息

  • 总下载量: 5.66k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-12-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固