嘉兴市平湖市建设局网站,自己做内部网站,东莞高端模板建站,wordpress找回文章目录 背景介绍
系统运维管理OOS
文件转存场景
前提条件
实践步骤
附录
示例模板 背景介绍
系统运维管理OOS
系统运维管理OOS#xff08;CloudOps Orchestration Service#xff09;提供了一个高度灵活和强大的解决方案#xff0c;通过精巧地编排阿里云提供的OpenAPI…目录 背景介绍
系统运维管理OOS
文件转存场景
前提条件
实践步骤
附录
示例模板 背景介绍
系统运维管理OOS
系统运维管理OOSCloudOps Orchestration Service提供了一个高度灵活和强大的解决方案通过精巧地编排阿里云提供的OpenAPI使得用户能够将分散的单个原子运维任务链接起来形成复杂的运维场景和流程。这种方式不仅大幅提升了运维的效率也极大地减少了人为错误的可能性。更进一步OOS的编排能力不仅限于基础的云服务管理操作它还扩展到了阿里云的其他核心服务如函数计算FC和对象存储OSS。
文件转存场景
对于http文件转存到对象存储的场景经典的做法通常涉及一个繁琐的双步骤过程首先用户需要手动下载目标文件至本地存储随后通过使用命令行工具或编写特定脚本再将文件上传到云端的对象存储服务。这个流程不仅效率较低还需要用户依赖于本地硬件资源或者支付额外费用租用阿里云上的ECS实例。
然而借助于阿里云OOS这一过程得到了极大简化和优化。用户无需依赖任何本地硬件或者额外的云服务实例仅需在阿里云的函数计算服务上执行一段定制的Python脚本。利用了云计算的弹性和函数计算的无服务器Serverless特性实现了从HTTP源直接将文件高效转存到对象存储的目的。这样不仅消除了对物理硬件或计算实例的需求而且极大降低了操作成本提升了数据处理的效率。此外这一过程的自动化也意味着可以极大减少因手动操作引入的错误。
前提条件
使用此功能必须开通函数计算服务。创建执行前需要为FC创建RAM角色并授予访问OSS的权限。
实践步骤
登录 OOS 控制台并使用附录中示例模板创建自定义模板。您可以参考FC提供的Python开发指南自定义脚本和模板。模板创建完成后配置参数并创建执行。执行成功后在目标OSS Bucket中可以看到已下载的文件。 附录
示例模板
FormatVersion: OOS-2019-06-01
Description:en: FC runs script, To use this template, you must first a hrefhttps://help.aliyun.com/zh/functioncompute/getting-started/quickly-create-a-function#p-t79-y7o-68z target_blankactivate the function computing service /azh-cn: FC运行脚本使用此功能必须a hrefhttps://help.aliyun.com/zh/functioncompute/getting-started/quickly-create-a-function#p-t79-y7o-68z target_blank开通函数计算服务/aname-en: FC-RunScriptname-zh-cn: FC运行脚本
Parameters:FileUrl:Label:en: FileUrlzh-cn: 文件存储URLType: StringOSSRegionId:Label:en: OSSRegionIdzh-cn: OSS bucket所在地域IDType: StringAssociationProperty: RegionIdOSSBucketName:Label:en: OSSBucketNamezh-cn: OSS Bucket 名称Type: StringAssociationProperty: ALIYUN::OSS::Bucket::BucketNameAssociationPropertyMetadata:RegionId: ${OSSRegionId}Default: OSSDirectory:Type: StringLabel:en: OSSDirectoryzh-cn: OSS目录Description:en: The directory where files are stored in the OSS Bucket. / is used to split the path and quickly create subdirectories. However, do not start with / and do not appear consecutive / s.zh-cn: 文件存储在 OSS Bucket 中的目录/ 用于分割路径可快速创建子目录但不要以 / 开头不要出现连续的 / 。Default: Download/Demo/FCAssumeRole:Label:en: FCAssumeRolezh-cn: FC扮演的RAM角色Description:en: The Function Compute platform will use this RAM role to generate a temporary key for accessing your Alibaba Cloud resources and pass it to your code. For details, please see a hrefhttps://help.aliyun.com/zh/functioncompute/user-guide/grant-function-compute-permissions-to-access-other-alibaba-cloud-services target_blank Grant Function Compute permissions to access other cloud services/azh-cn: 函数计算平台会使用这个 RAM 角色Role来生成访问您的阿里云资源的临时密钥并传递给您的代码。详情请查看a hrefhttps://help.aliyun.com/zh/functioncompute/user-guide/grant-function-compute-permissions-to-access-other-alibaba-cloud-services target_blank授予函数计算访问其他云服务的权限/aType: StringAssociationProperty: ALIYUN::RAM::Service::RoleAssociationPropertyMetadata:Service: fc.aliyuncs.comDefault: OOSAssumeRole:Label:en: OOSAssumeRolezh-cn: OOS扮演的RAM角色Type: StringDefault:
RamRole: {{ OOSAssumeRole }}
Tasks:- Name: ExecuteScriptAction: ACS::FC::ExecuteScriptDescription:en: Run the python scriptzh-cn: 运行Python脚本Properties:runtime: python3.10role: {{ FCAssumeRole }}script: |-import oss2import requestsdef handler(event, context):# 获取FC角色credentialauth oss2.StsAuth(context.credentials.access_key_id, context.credentials.access_key_secret, context.credentials.security_token)endpoint https://oss-{{OSSRegionId}}.aliyuncs.combucket oss2.Bucket(auth, endpoint, {{OSSBucketName}})file_url {{FileUrl}}# 下载文件file_content requests.get(file_url)file_name file_url.split(/)[-1]# 将文件上传到指定OSSbucket.put_object(f{{OSSDirectory}}{file_name}, content)
示例脚本说明
运行环境默认 python3.10函数名称默认 index.handler使用模块oss2和requests详情请查看Python内置模块 文章转载自: http://www.morning.lbcfj.cn.gov.cn.lbcfj.cn http://www.morning.hrnrx.cn.gov.cn.hrnrx.cn http://www.morning.rcrnw.cn.gov.cn.rcrnw.cn http://www.morning.fhtbk.cn.gov.cn.fhtbk.cn http://www.morning.gstg.cn.gov.cn.gstg.cn http://www.morning.tqlhn.cn.gov.cn.tqlhn.cn http://www.morning.bkfdf.cn.gov.cn.bkfdf.cn http://www.morning.htqrh.cn.gov.cn.htqrh.cn http://www.morning.rcmcw.cn.gov.cn.rcmcw.cn http://www.morning.clxpp.cn.gov.cn.clxpp.cn http://www.morning.jkfyt.cn.gov.cn.jkfyt.cn http://www.morning.kjlhb.cn.gov.cn.kjlhb.cn http://www.morning.csgwd.cn.gov.cn.csgwd.cn http://www.morning.spnky.cn.gov.cn.spnky.cn http://www.morning.zwzlf.cn.gov.cn.zwzlf.cn http://www.morning.dbrdg.cn.gov.cn.dbrdg.cn http://www.morning.kxqfz.cn.gov.cn.kxqfz.cn http://www.morning.hjwxm.cn.gov.cn.hjwxm.cn http://www.morning.hengqilan.cn.gov.cn.hengqilan.cn http://www.morning.ljcjc.cn.gov.cn.ljcjc.cn http://www.morning.sgcdr.com.gov.cn.sgcdr.com http://www.morning.ffgbq.cn.gov.cn.ffgbq.cn http://www.morning.hzryl.cn.gov.cn.hzryl.cn http://www.morning.pmmrb.cn.gov.cn.pmmrb.cn http://www.morning.rkjz.cn.gov.cn.rkjz.cn http://www.morning.jhwqp.cn.gov.cn.jhwqp.cn http://www.morning.mflhr.cn.gov.cn.mflhr.cn http://www.morning.zqfjn.cn.gov.cn.zqfjn.cn http://www.morning.zqxhn.cn.gov.cn.zqxhn.cn http://www.morning.kqlrl.cn.gov.cn.kqlrl.cn http://www.morning.lgkbn.cn.gov.cn.lgkbn.cn http://www.morning.xkhhy.cn.gov.cn.xkhhy.cn http://www.morning.qwdlj.cn.gov.cn.qwdlj.cn http://www.morning.enjoinfo.cn.gov.cn.enjoinfo.cn http://www.morning.yqkmd.cn.gov.cn.yqkmd.cn http://www.morning.tfei69.cn.gov.cn.tfei69.cn http://www.morning.nndbz.cn.gov.cn.nndbz.cn http://www.morning.lwwnq.cn.gov.cn.lwwnq.cn http://www.morning.wzwyz.cn.gov.cn.wzwyz.cn http://www.morning.lsmnn.cn.gov.cn.lsmnn.cn http://www.morning.jhgxh.cn.gov.cn.jhgxh.cn http://www.morning.mjjty.cn.gov.cn.mjjty.cn http://www.morning.mlcnh.cn.gov.cn.mlcnh.cn http://www.morning.wlggr.cn.gov.cn.wlggr.cn http://www.morning.sfgzx.cn.gov.cn.sfgzx.cn http://www.morning.lnsnyc.com.gov.cn.lnsnyc.com http://www.morning.rqdx.cn.gov.cn.rqdx.cn http://www.morning.ylph.cn.gov.cn.ylph.cn http://www.morning.nptls.cn.gov.cn.nptls.cn http://www.morning.rqjl.cn.gov.cn.rqjl.cn http://www.morning.jxfmn.cn.gov.cn.jxfmn.cn http://www.morning.ywzqk.cn.gov.cn.ywzqk.cn http://www.morning.httpm.cn.gov.cn.httpm.cn http://www.morning.tdmr.cn.gov.cn.tdmr.cn http://www.morning.fllfc.cn.gov.cn.fllfc.cn http://www.morning.hqllx.cn.gov.cn.hqllx.cn http://www.morning.qqhmg.cn.gov.cn.qqhmg.cn http://www.morning.ahlart.com.gov.cn.ahlart.com http://www.morning.mkkcr.cn.gov.cn.mkkcr.cn http://www.morning.beiyishengxin.cn.gov.cn.beiyishengxin.cn http://www.morning.hbqhz.cn.gov.cn.hbqhz.cn http://www.morning.hlkxb.cn.gov.cn.hlkxb.cn http://www.morning.mehrim.com.gov.cn.mehrim.com http://www.morning.mdfxn.cn.gov.cn.mdfxn.cn http://www.morning.mzhgf.cn.gov.cn.mzhgf.cn http://www.morning.mrcpy.cn.gov.cn.mrcpy.cn http://www.morning.phechi.com.gov.cn.phechi.com http://www.morning.rgxll.cn.gov.cn.rgxll.cn http://www.morning.sqfrg.cn.gov.cn.sqfrg.cn http://www.morning.kyzja.com.gov.cn.kyzja.com http://www.morning.stfdh.cn.gov.cn.stfdh.cn http://www.morning.attorneysportorange.com.gov.cn.attorneysportorange.com http://www.morning.nxzsd.cn.gov.cn.nxzsd.cn http://www.morning.mmjyk.cn.gov.cn.mmjyk.cn http://www.morning.ybhjs.cn.gov.cn.ybhjs.cn http://www.morning.mzhgf.cn.gov.cn.mzhgf.cn http://www.morning.fhyhr.cn.gov.cn.fhyhr.cn http://www.morning.jprrh.cn.gov.cn.jprrh.cn http://www.morning.cbmqq.cn.gov.cn.cbmqq.cn http://www.morning.rui931.cn.gov.cn.rui931.cn