<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Python script on SAS 9.4 M7 in Administration and Deployment</title>
    <link>https://communities.sas.com/t5/Administration-and-Deployment/Python-script-on-SAS-9-4-M7/m-p/949414#M29209</link>
    <description>If your program "test.py" when run outputs the desired secret in plain text to stdout, then your solution to run it from a pipe and retrieve the output seems valid to me. &lt;BR /&gt;&lt;BR /&gt;The code in the linked SAS Explore presentation does not do that, it defines a function that is then called using PROC PYTHON to pull the secret object returned by the python function into a macro variable, so the python code would need to be modified to instead print the secret to stdout.</description>
    <pubDate>Tue, 29 Oct 2024 20:53:33 GMT</pubDate>
    <dc:creator>gwootton</dc:creator>
    <dc:date>2024-10-29T20:53:33Z</dc:date>
    <item>
      <title>Python script on SAS 9.4 M7</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Python-script-on-SAS-9-4-M7/m-p/949391#M29206</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My question may be very basic..It can be a straight forward answer like 'Yes' (or) 'no' &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Clients secrets are stored in Azure Key vault and I need to use those details to connect to snowflake using Oauth authentication. As we dont have SAS Viya yet, I'm written SAS code using proc http and then I able to use the Oauth functionaility. I have hardcoded the client secrets currently for time being. As per the suggestion, I have created the secure macro for storing the credentails&amp;nbsp; &amp;nbsp;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n0sjezyl65z1cpn1b6mqfo8115h2.htm" target="_blank"&gt;https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n0sjezyl65z1cpn1b6mqfo8115h2.htm&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But as per this documentation&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Explore-Presentations/Guarding-Secrets-in-SAS-Programs-With-Azure-Key-Vault/ta-p/896515" target="_blank"&gt;https://communities.sas.com/t5/SAS-Explore-Presentations/Guarding-Secrets-in-SAS-Programs-With-Azure-Key-Vault/ta-p/896515&lt;/A&gt;&amp;nbsp;, secrets can be retrieved using python code if we are in SAS Viya.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As we are in SAS 9.4M7 on RHEL servers, why cant we take this approach of getting the secrets from Azure vault ? Please let me know if it is not possible&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Install python on RHEL&lt;/P&gt;
&lt;P&gt;2. Install these two packages&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class="bash"&gt;pip install azure-identity&lt;BR /&gt;pip install azure-keyvault-secrets&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;3.Create a python file as mentioned in this documentation&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Explore-Presentations/Guarding-Secrets-in-SAS-Programs-With-Azure-Key-Vault/ta-p/896515" target="_blank"&gt;https://communities.sas.com/t5/SAS-Explore-Presentations/Guarding-Secrets-in-SAS-Programs-With-Azure-Key-Vault/ta-p/896515&lt;/A&gt;&amp;nbsp;and store it on the Linux server as test.py&lt;/P&gt;
&lt;P&gt;4. Then from SAS program , call the python script&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;filename cmd pipe "python test.py";&lt;/P&gt;
&lt;P&gt;data work.secret;&lt;/P&gt;
&lt;P&gt;infile cmd;&lt;/P&gt;
&lt;P&gt;input;&lt;/P&gt;
&lt;P&gt;put _infile_;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;5. Get the client secret from the work.secret data set and assign it to macro variable and then pass it to the connection string to snowflake.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I dont know much about Python and seriously the above approach may be not achievable at all . Please let me know your thoughts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2024 17:54:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Python-script-on-SAS-9-4-M7/m-p/949391#M29206</guid>
      <dc:creator>freshstarter</dc:creator>
      <dc:date>2024-10-29T17:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: Python script on SAS 9.4 M7</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Python-script-on-SAS-9-4-M7/m-p/949404#M29207</link>
      <description>&lt;P&gt;Getting an official response from SAS Tech Support by opening a support track is the best option here for such a specialist topic.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2024 19:34:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Python-script-on-SAS-9-4-M7/m-p/949404#M29207</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2024-10-29T19:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: Python script on SAS 9.4 M7</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Python-script-on-SAS-9-4-M7/m-p/949413#M29208</link>
      <description>&lt;P&gt;Should work if you have ability to run shell commands turned on in your SAS session so that the PIPE will work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But how it is any better or easier than what you already created with PROC HTTP?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2024 20:52:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Python-script-on-SAS-9-4-M7/m-p/949413#M29208</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-10-29T20:52:03Z</dc:date>
    </item>
    <item>
      <title>Re: Python script on SAS 9.4 M7</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Python-script-on-SAS-9-4-M7/m-p/949414#M29209</link>
      <description>If your program "test.py" when run outputs the desired secret in plain text to stdout, then your solution to run it from a pipe and retrieve the output seems valid to me. &lt;BR /&gt;&lt;BR /&gt;The code in the linked SAS Explore presentation does not do that, it defines a function that is then called using PROC PYTHON to pull the secret object returned by the python function into a macro variable, so the python code would need to be modified to instead print the secret to stdout.</description>
      <pubDate>Tue, 29 Oct 2024 20:53:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Python-script-on-SAS-9-4-M7/m-p/949414#M29209</guid>
      <dc:creator>gwootton</dc:creator>
      <dc:date>2024-10-29T20:53:33Z</dc:date>
    </item>
    <item>
      <title>Re: Python script on SAS 9.4 M7</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Python-script-on-SAS-9-4-M7/m-p/949433#M29210</link>
      <description>&lt;P&gt;By looking at the presentation you shared for the approach under Viya I believe this could work very similarly under SAS9.4.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You obviously don't have Proc Python under SAS9.4 but you can still run a Python script out of SAS (as a child process, for example using the system() function).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the presentation the secret retrieved by the Python script gets then stored in a macro variable used in the SAS code as value for the libname password parameter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As far as I understand it for an implementation under SAS9.4 the only changes required would be how you call the Python script out of SAS and how you pass back the secret from Python to the parent SAS process. All the rest should work the same.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So like in your step for a call of a Python script that returns the secret.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename cmd pipe "python test.py";
data _null_;
  infile cmd;
  input;
  call symputx('KVSecret',_infile_);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2024 23:41:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Python-script-on-SAS-9-4-M7/m-p/949433#M29210</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-10-29T23:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: Python script on SAS 9.4 M7</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Python-script-on-SAS-9-4-M7/m-p/949774#M29213</link>
      <description>Thank you for all your suggestio. I ll give a try and keep you informed .</description>
      <pubDate>Sat, 02 Nov 2024 10:06:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Python-script-on-SAS-9-4-M7/m-p/949774#M29213</guid>
      <dc:creator>freshstarter</dc:creator>
      <dc:date>2024-11-02T10:06:06Z</dc:date>
    </item>
  </channel>
</rss>

