私信  •  关注

Peter Pan

Peter Pan 最近创建的主题
Peter Pan 最近回复了
5 年前
回复了 Peter Pan 创建的主题 » Microsoft azure中的Python库

是个包裹 azure-monitor 您在旧版本的Azure SDK for Python中用于Azure服务管理,GitHub repo标记是 azure-monitor_0.3.1 . 你可以在 https://pypi.org/project/azure-monitor/ .

为了安装它,我用当前的Python创建了一个虚拟环境 3.6.7 . 这是我的脚步。

  1. 命令 virtualenv azure-monitor-test cd azure-monitor-test
  2. 命令 source bin/activate
  3. 命令 pip install azure-monitor
  4. 跑步 from azure.monitor import MonitorClient 在我的Python解释器中获得成功,如下图所示。

enter image description here

  1. 通过命令检查我安装的pip包 pip list | grep azure ,然后您将看到其相关包的这些版本,如下所示。

enter image description here

5 年前
回复了 Peter Pan 创建的主题 » 通过python库调用AudioConfig.FromWavFileInput函数时出现问题

确实如你所说。我搜索关键字 AudioConfig &安培; FromWavFileInput 关于GitHub回购 Azure-Samples/cognitive-services-speech-sdk ,除了Java、C#和 C++ .

根据我的经验,有两种解决方法。

  1. 将C++代码打包为 Python extension module ,或者与C++/Java代码通信。
  2. 直接使用 Speech service REST APIs 具有 requests ,对于Python和Azure语音服务来说很简单。
5 年前
回复了 Peter Pan 创建的主题 » 使用python脚本从azure服务器发送电子邮件

首先,请按照官方文件 How to set up a multifunction device or application to send email using Office 365 以确保设置是否正确。

其次,如果您使用azure vm通过smtp发送邮件,则可以参考此文档 Understand outbound SMTP problems in Azure VMs 试图解决你的问题。

同时,对于编码,有一些资源可能会有帮助。

  1. Python: Send Email via Office 365
  2. Send email on App Service using Office 365 (O365) 在php中
  3. Sending email from an Azure App Service using an O365 SMTP server 在C中#

或者直接使用一些包,如python-o365: GitHub PyPI 是的。

最后,还有一个名为sendGrid的服务用于电子邮件服务。你可以使用它在azure上的场景中发送邮件,请参考官方教程了解 How to Send Email Using SendGrid with Azure (c)。对于python,可以通过 its REST API sendgrid python library 是的。

4 年前
回复了 Peter Pan 创建的主题 » 无法安装azure cli,找不到python2 virtualenv

正如我所知, azure-cli 不需要 python-virtualenv ,您可以看到 requirements.txt 它的github repo文件,如下所示。

enter image description here

正如@4c74356b41在评论中所说,您可以安装 azure-cli 通过 pip ,因为你可以在pypi.org上找到它。

例如,我在wsl的python3中创建了一个虚拟环境,您将看到我安装了 天蓝CLI 通过 匹普 之后 source bin/activate ,然后 deactivate 它和设置 PATH 变量 az 路径通过 which az ,我也可以使用 阿兹 通常情况下。

图1。创建名为 az_test 激活它安装 天蓝CLI 通过 匹普

enter image description here

图2。安装后, 阿兹 在虚拟环境中工作。

enter image description here

图3。不需要 virtualenv .

enter image description here

图4。即使我停用虚拟环境,并添加 阿兹 通往 路径 ,它也可以工作

enter image description here

最后,您可以直接安装 天蓝CLI 在RHEL7或CentOS7的AWS虚拟机中,通过命令 sudo pip install azure-cli 当安装了 匹普 pip3 通过 yum .

希望有帮助。

5 年前
回复了 Peter Pan 创建的主题 » azure对函数应用使用python烧瓶框架

我尝试了不同的方法将azure的python函数与flask框架集成。最后,我在名为 TryFlask 通过 app.test_client() .

这是我的示例代码,如下所示。

import logging
import azure.functions as func
from flask import Flask, request

app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello World!'

@app.route('/hi')
def hi():
    return 'Hi World!'

@app.route('/hello')
@app.route('/hello/<name>', methods=['POST', 'GET'])
def hello(name=None):
    return name != None and 'Hello, '+name or 'Hello, '+request.args.get('name')

def main(req: func.HttpRequest) -> func.HttpResponse:
    logging.info('Python HTTP trigger function processed a request.')
    uri=req.params['uri']
    with app.test_client() as c:
        doAction = {
            "GET": c.get(uri).data,
            "POST": c.post(uri).data
        }
        resp = doAction.get(req.method).decode()
        return func.HttpResponse(resp, mimetype='text/html')

在本地和azure上测试时,访问url / ,‘嗨’ /hello 通过URL http(s)://<localhost:7071 or azurefunchost>/api/TryFlask 带查询字符串 ?uri=/ , ?uri=/hi ?uri=/hello/peter-pan 在浏览器中,并执行 POST 方法使用查询字符串访问上面的同一URL。 ?uri=/hello/彼得潘 ,这些都是工作。请将结果作为下面的本地数字查看,与云上的结果相同。

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

注意:在我的解决方案中,url必须是 http(s)://<localhost:7071 or azurefunchost>/<routePrefix defined in host.json, default is api>/<function name>?uri=<uri defined in app.route, like / or /hi or /hello, even /hello/peter-pan?name=peter> .