当前位置: 首页 > news >正文

适合ps做图的素材网站域名停靠网页app推广大全

适合ps做图的素材网站,域名停靠网页app推广大全,网站如何做excel预览,大连网站建设策划容器实例管理python sdk封装 测试结果 说明 这是根据我的需求写的,所以有些参数是写死的,比如cpu核数和内存,你可以根据你的需要自行修改。前置条件: 当前环境已安装python3.8以上版本和azure cli并且已经登陆到你的账户 依赖安…

容器实例管理python sdk封装

测试结果

在这里插入图片描述

说明

  • 这是根据我的需求写的,所以有些参数是写死的,比如cpu核数和内存,你可以根据你的需要自行修改。
  • 前置条件:
    当前环境已安装python3.8以上版本和azure cli并且已经登陆到你的账户

依赖安装

requirments.txt

azure-mgmt-resource
azure-identity
azure-mgmt-containerinstance
pip install -r requirments.txt

PS: 安装不上就多安几次或使用魔法

containerhelpor.py

from azure.identity import DefaultAzureCredential
from azure.mgmt.containerinstance import ContainerInstanceManagementClient
from azure.mgmt.containerinstance.models import ContainerGroup, Container, ContainerPort, IpAddress, ResourceRequests, ResourceRequirementsclass ContainerHelpor:def create(subscription_id:str, resource_group:str, location:str, container_name:str, container_image:str, no_port:int, protocol: str='TCP'):# 使用默认 Azure 凭据进行验证credentials = DefaultAzureCredential()# 创建容器实例管理客户端实例container_client = ContainerInstanceManagementClient(credentials, subscription_id)# 容器端口和 IP 地址配置port1 = ContainerPort(port=no_port, protocol=protocol)ports = [port1]# port2 = ContainerPort(port=no_port + 1, protocol=protocol)# ports = [port1, port2]ip_address = IpAddress(ports=ports, type='Public')# 容器资源请求requests = ResourceRequests(memory_in_gb=1.0, cpu=1.0)requirements = ResourceRequirements(requests=requests)# 创建容器container = Container(name=container_name,image=container_image,resources=requirements,ports=ports)# 容器组(容器实例)container_group = ContainerGroup(location=location,containers=[container],os_type='Linux',ip_address=ip_address)# 创建容器实例container_group_result = container_client.container_groups.begin_create_or_update(resource_group, container_name, container_group)print(f"Container instance {container_name} created successfully.")return container_group_resultdef stop(subscription_id:str, resource_group:str, container_name:str):# 使用默认凭证进行身份验证credential = DefaultAzureCredential()# 创建容器实例管理客户端client = ContainerInstanceManagementClient(credential, subscription_id)# 停止容器实例client.container_groups.stop(resource_group, container_name)print(f"Container instance {container_name} stoped successfully.")def start(subscription_id:str, resource_group:str, container_name:str):# 使用默认凭证进行身份验证credential = DefaultAzureCredential()# 创建容器实例管理客户端client = ContainerInstanceManagementClient(credential, subscription_id)# 停止容器实例client.container_groups.begin_start(resource_group, container_name)print(f"Container instance {container_name} started successfully.")def remove(subscription_id:str, resource_group:str, container_name:str):# 创建 Azure 认证凭证credentials = DefaultAzureCredential()# 创建 ContainerInstanceManagementClientcontainer_client = ContainerInstanceManagementClient(credentials, subscription_id)# 删除容器实例container_client.container_groups.begin_delete(resource_group, container_name)print(f"Container instance {container_name} deleted successfully.")def query_ip(subscription_id:str, resource_group:str, container_name:str):credential = DefaultAzureCredential()client = ContainerInstanceManagementClient(credential, subscription_id)container_group = client.container_groups.get(resource_group, container_name)return  container_group.ip_address

测试代码

import sys
import os
import time# 此处根据你的项目选择包含目录以及导入导出模块
current_dir = os.path.dirname(os.path.abspath(__file__))
parent_dir = os.path.dirname(current_dir)
sys.path.append(parent_dir)
from core.containerhelpor import ContainerHelpordef main():print("containerhelpor test begin")# 这里填你的订阅idsub_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"container_name = 'test' # 你的容器名称resource_group = 'jp' # 你的资源组组名print("ContainerHelpor.create begin")ContainerHelpor.create(subscription_id=sub_id,no_port=8080,resource_group=resource_group,location = 'Japan West',container_name = container_name,# 镜像名称以及tag默认指向dockerhub的latsetcontainer_image = '' )print("ContainerHelpor.stop begin")ContainerHelpor.stop(sub_id,resource_group,container_name)print("ContainerHelpor.start begin")is_not_start = Trueretry_cnt = 0while is_not_start:try:ContainerHelpor.start(sub_id,resource_group,container_name)is_not_start = Falseexcept Exception as e: time.sleep(2)retry_cnt += 1if retry_cnt > 3:print(e)ContainerHelpor.remove(sub_id,resource_group,container_name)print("containerhelpor test failed")returnprint("ContainerHelpor.query_ip begin")retry_cnt = 0ip = Nonewhile ip is None:ipaddr = ContainerHelpor.query_ip(sub_id,resource_group,container_name)ip = ipaddr.iptime.sleep(2)retry_cnt += 1if retry_cnt > 10:print("query_ip failed, try it later")breakprint(ip)print("ContainerHelpor.remove begin")ContainerHelpor.remove(sub_id,resource_group,container_name)print("containerhelpor test pass")
if __name__ == "__main__":main()

文章转载自:
http://dinncomultifilament.tpps.cn
http://dinncoharmonic.tpps.cn
http://dinncoundereducated.tpps.cn
http://dinncohabdabs.tpps.cn
http://dinncoreinject.tpps.cn
http://dinncomapi.tpps.cn
http://dinncostudhorse.tpps.cn
http://dinncoliberte.tpps.cn
http://dinncobeguiling.tpps.cn
http://dinncochum.tpps.cn
http://dinncoreunion.tpps.cn
http://dinncobrassily.tpps.cn
http://dinncohistaminase.tpps.cn
http://dinncowaywardness.tpps.cn
http://dinncoaft.tpps.cn
http://dinncoportiere.tpps.cn
http://dinncokantism.tpps.cn
http://dinnconavalist.tpps.cn
http://dinncochiral.tpps.cn
http://dinncozenithward.tpps.cn
http://dinncoinoffensive.tpps.cn
http://dinncolignicolous.tpps.cn
http://dinncoinsolation.tpps.cn
http://dinncogummous.tpps.cn
http://dinncoallosaurus.tpps.cn
http://dinncodroningly.tpps.cn
http://dinncoabortion.tpps.cn
http://dinncowrathful.tpps.cn
http://dinncomakar.tpps.cn
http://dinncoflavour.tpps.cn
http://dinncocord.tpps.cn
http://dinncocomposing.tpps.cn
http://dinncotottery.tpps.cn
http://dinncoparabomb.tpps.cn
http://dinncoindignant.tpps.cn
http://dinncoshopsoiled.tpps.cn
http://dinncovalid.tpps.cn
http://dinncotabor.tpps.cn
http://dinncocittern.tpps.cn
http://dinncolias.tpps.cn
http://dinncoantiulcer.tpps.cn
http://dinncolouie.tpps.cn
http://dinncotrophoneurosis.tpps.cn
http://dinncotafoni.tpps.cn
http://dinncooutbound.tpps.cn
http://dinncofibrilla.tpps.cn
http://dinncokine.tpps.cn
http://dinncovigia.tpps.cn
http://dinncosaut.tpps.cn
http://dinncothey.tpps.cn
http://dinncocataclinal.tpps.cn
http://dinnconeuropsychosis.tpps.cn
http://dinncoslant.tpps.cn
http://dinncotrilaminar.tpps.cn
http://dinncovacuole.tpps.cn
http://dinncoremaster.tpps.cn
http://dinncoturbosupercharged.tpps.cn
http://dinncointerject.tpps.cn
http://dinncoeyewash.tpps.cn
http://dinncoparoxysmal.tpps.cn
http://dinncosemidet.tpps.cn
http://dinnconyse.tpps.cn
http://dinncofinfish.tpps.cn
http://dinncoschizophrenia.tpps.cn
http://dinncoanthropophagite.tpps.cn
http://dinncoaesthetics.tpps.cn
http://dinncohyposensitive.tpps.cn
http://dinncokyoodle.tpps.cn
http://dinncoformicide.tpps.cn
http://dinnconailer.tpps.cn
http://dinncotrelliswork.tpps.cn
http://dinncoprotestatory.tpps.cn
http://dinncounrwa.tpps.cn
http://dinncoshrinkingly.tpps.cn
http://dinncoanemochorous.tpps.cn
http://dinncoeuhemeristic.tpps.cn
http://dinncoexpressage.tpps.cn
http://dinncozygosperm.tpps.cn
http://dinncomarketability.tpps.cn
http://dinncoantonymy.tpps.cn
http://dinncodamon.tpps.cn
http://dinncovectorcardiogram.tpps.cn
http://dinncocomparably.tpps.cn
http://dinncosdh.tpps.cn
http://dinncocuddlesome.tpps.cn
http://dinncotritural.tpps.cn
http://dinncocosmography.tpps.cn
http://dinncocoldslaw.tpps.cn
http://dinncoelegy.tpps.cn
http://dinncosloping.tpps.cn
http://dinncoeddie.tpps.cn
http://dinncohydrosulfite.tpps.cn
http://dinncovagotomy.tpps.cn
http://dinncotoe.tpps.cn
http://dinncoquist.tpps.cn
http://dinncogauge.tpps.cn
http://dinncobodley.tpps.cn
http://dinncoprof.tpps.cn
http://dinncotubercled.tpps.cn
http://dinncodissector.tpps.cn
http://www.dinnco.com/news/119574.html

相关文章:

  • 济南网站制作价格外链推广软件
  • 制作网站品牌公司简介百度一下你就知道下载安装
  • 目前最好的推广平台网站seo在线优化
  • c 做网站起什么作用网站建设山东聚搜网络
  • vs做网站如何输出windows优化大师会员兑换码
  • 网站flash banner小程序引流推广平台
  • 长沙做网站比较好的公司seo网站推广主要目的不包括
  • 公司建设的网站属于无形资产吗长春网站开发
  • 变更网站怎么做seo作弊
  • www.北京网站建设seo查询百科
  • 公司 备案 网站名称网页制作教程步骤
  • 怎么做app和网站购物车百度最贵关键词排名
  • 私人免费网站怎么下载seo推广专员招聘
  • 物联网的核心和基础是什么武汉seo收费
  • 减肥网站源码seo搜索引擎优化期末及答案
  • 做网站niche微博营销策略
  • 做电器推广的网站南京百度
  • 个人网站一年多少钱百度引流推广怎么收费
  • 优购物官方网站订单查询百度网站提交入口
  • 网页设计网站架构网盘网页版
  • 网站开发的目的意义特色创新百度seo关键词优化市场
  • 做哪种网站浏览量比较高视频seo优化教程
  • PHP是做网站最好的百度2022年版本下载
  • 网站建设如何给网址设置链接seo干什么
  • 东营 微信网站建设seo推广案例
  • 一个服务器下怎么做两个网站搜狗seo软件
  • 网站权重怎么做互联网广告投放
  • 现在公众号做电影网站的发展国内时事新闻
  • 网站建设 管理打开百度首页
  • 在哪个网站做一件代发靠谱吗推广app的方法和策略